0

i am trying get a element through selenium with code:

WebElement a = driver.findElement(By.xpath("//div[@id=':r6']/span/text()"));

using this same expression on a firefox plugin, the element is find , but in selenium(java code) this way the element is not found, someone can me help

1

2 Answers 2

1

The command that you might need is: "AllowNativeXPath" - then just use the Xpath (either via Xpather or after 'inspecting element')to identify your element. Sometimes, though ... there's still an issue where Selenium does not 'see' elements described with an Xpath while running a script, but when users click the 'Find' button ... Selenium has no trouble at all. I usually take the focus up a level and down a level before any commands that Selenium has trouble finding the elements for ... and it works well thereafter. It's ugly and very NOT elegant ... but it works.

Selenium uses it's OWN Xpath interpreter ... and the one native to your browser might be better in some cases.

Sign up to request clarification or add additional context in comments.

Comments

0

You can try this instead:

WebElement a = driver.findElement(By.xpath("//div[@id=':r6']/span")).getText();

Comments

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.