I am writing Selenium script. For a html page include a table, I can not use "css=table tr:nth-child(2) td:nth-child(3) a" to locate the link in the table. Selenium IDE give me the "[error] locator not found".
But use "css=table tr:nth-child(2)", it can locate to the row. So am I mistake for the css locator, I think adding the "td:nth-child(3) a" should work for the link in td , why not?
Edit: I am using firefox 3.0.15
Given the HTML:
<html>
<body>
<table>
<tr><td>Hello</td><td>World</td></tr>
<tr><td>I'm</td><td><a href="http://www.example.com/">Batman</a></td></tr>
</table>
</body>
</html>
You can use the following locator for the link in the 2nd column of the 2nd row:
css=tr:nth-child(2) > td:nth-child(2) > a
Update:
After a little bit of research, it seems your original locator should work, but doesn't due to a bug in the cssQuery library used by Selenium (http://jira.openqa.org/browse/SEL-698). My suggestion above works, but it's really only a workaround until the bug is fixed. Unfortunately, considering the cssQuery hasn't been updated for some time I'm not sure how soon this will be addressed.
A similar issue is still around in Selenium IDE 2.1.0
I'm testing a group of web sites to check if a specific URL has been changed.
The link I'm supposed to check for is in a table, in the 25th or so tr from the top ...
<tr>
<td>
<div align="center">
<font color="#FFFFFF">
<a target="_blank" href="http://[The link I need to test] ...
I've used both
assertElementPresent //*[starts-with(@href,'The Link')]
and
assertElementPresent //*[contains(@*,'The Link')]
In some cases, the first one will find a result, but the second one will not. Most of the time neither will find the Link.
精彩评论