How to select font node in Sahi?
-
30-06-2021 - |
Question
I am using Sahi to record my actions in IE8. My page contains this markup:
<td id="ButtonText" class="myClass">
<font title="unique title" onclick="CallThis()">ButtonText</font>
</td>
When I click the button defined above, Sahi records:
_click(_cell("Button Text"));
But when I play this back, the button is not clicked. However,
_assertExists(_cell("Button Text"));
returns true.
I have added the following line into the concat.js file to try to make it detect font nodes:
this.addAD({tag: "FONT", type: "null", event:"click", name: "_font", attributes: ["sahiText", "title|alt", "id", "index", "href", "className"], action: "_click", value: "sahiText"});
but this doesn't seem to have had any effect (I have restarted Sahi). I don't have any control over the page being tested and I am not sure whether the td node or the font node is being selected.
How do I fire the onclick event of the font node?
EDIT: I have added _font to sahi/config/normal_functions.txt
Manually tweaking the page using IE tools to have the onclick even on the td results in the same steps being recorded, but it will now play it back.
<td id="ButtonText" class="myClass" onclick="CallThis()">
<font title="unique title">ButtonText</font>
</td>
Unfortunately I am unable to make any changes to the page and I still need to playback the onclick event which exists on the font node.
Both
_font("ButtonText");
_font("unique title");
give
[Exception] [object Error]
Solution
The solution to the problem was to remove the quotes around "null":
this.addAD({tag: "FONT", type: null, event:"click", name: "_font", attributes: ["sahiText", "title|alt", "id", "index", "href", "className"], action: "_click", value: "sahiText"});
OTHER TIPS
Add _font to sahi/config/normal_functions.txt, restart Sahi and check.
Regards, Narayan