KallDrexx
KallDrexx

Reputation: 27803

Selenium cannot find element by text via xpath

I am trying to click on some text that is inside of a menu item (I can't use the menu item's id since it's an asp.net webforms menu that has no client ids, thus the ids are unreliable). Inside the table cell there is

<nobr>Revenue Object Maintenance</nobr>

However, if I do:

selenium.Click("xpath=//nobr[text()='Revenue Object Maintenance'");

Selenium errors out:

ERROR: Invalid xpath [3]: XPath parse error //nobr[text()='Revenue Object Maintenance'

How can I click on this nobr instance?

Upvotes: 3

Views: 4012

Answers (1)

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243449

if I do:

selenium.Click("xpath=//nobr[text()='Revenue Object Maintenance'"); 

Selenium errors out:

The error is obvious: you haven't closed the predicate.

This is a syntactically correct XPath expression:

//nobr[text()='Revenue Object Maintenance']

Upvotes: 2

Related Questions