Reputation: 96484
I try to use css locators over xpath when I can.
I have the following xpath locator that I would like to change to css:
//table[@id='service_schedule_sets']//a[text()='OptimalTest']
I would like to use a css locator. I wish to avoid using contains as there are support issues in later versions of css (i.e. contains
was removed from css2 and css3 (css2 removal was a very last minute thing) that selenium covers up but I would like to avoid.
I am trying:
css=table#service_schedule_sets a[.='OptimalTest')
but it doesn't find the element.
The HTML is:
<td>
<a href="service_schedule_sets/905">OptimalTest</a>
</td>
Notes:
I want to use the text in the link ('OptimalTest') not the href. I do not want to use link=OptimalTest approach as it is not specific enough.
Upvotes: 3
Views: 897
Reputation: 13853
CSS selectors do not support node selection based on their text content.
Actually there was a suggestion for a pseudo class :contains
which would suit your needs, but it was removed from CSS 3 spec.
Upvotes: 1