0

I want to select the second match of my path in a document in selenium IDE: This is the path. I am sure it is valid because Firebug can find it with no problems

(//label[text() = "stupid"])[2]

Selenium does not think this is an element. I don't even think it recognizes it as a valid path.

[error] locator not found: (//label[text() = "stupid"])[2]
1
  • also, how do I get markdown to not treat // as a comment? Commented Apr 9, 2013 at 14:48

3 Answers 3

2

You need to use the "xpath=" label if the locator is not starting with "//". Yours is starting with "(" so:

xpath=(//label[text() = "stupid"])[2]
Sign up to request clarification or add additional context in comments.

Comments

1

In this case, selenium needs to be told that the locator is an Xpath.

this can be accomplished by appending (with no whitespace)"xpath="to the head of the locator.

2 Comments

Please put the version of Selenium you are using next time. The old RC API only applies to this.
@Arran The Q is tagged "selenium-ide", so it's not WebDriver.
0

try this

driver.findElement(By.xpath("//label[text() = 'stupid'])[2]"));

remember in Java " "(parenthesis) , needs to be escaped or replace it either using ' ' or \"

1 Comment

The question is about Selenese, not Java.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.