3

I'm using Chromedriver to try and find the following element:

<td class="section-menuoption"
  onmouseover="this.className='section-menuoption-hilite';"
  onmouseout="this.className='section-menuoption';" align="left"
  onclick="self.jssDetails.location='products.php?xUser=kery&amp;xRand=123';">
  Scheduled Changes
</td>

When using the SeleniumIDE in Firefox I can use this selector without issue:

//*[contains(text(), 'Scheduled Changes')] 

However, when I attempt to use this selector with the Chromedriver I get a "no such element" error (running via maven). My Chromedriver code looks likes this:

WebElement box = driver.findElement(By.xpath("//*[contains(text(), 'Scheduled Changes')]"));
System.out.print(box.getText());
box.click();

I've tried different quoting strategies, different xpaths (that also resolve correctly in the SeleniumIDE), but with no success. The only thing I can think of now is changing my XPath implementation, but I'm not even sure that's possible with Chromedriver.

Any help would be very appreciated.

1 Answer 1

3

First, make sure it it not in any kind of frames. Otherwise you need switch into the frame first, like this.

Then try use css selector instead of XPath. For example (you may need try different variations):

WebElement box = driver.findElement(By.cssSelector("td[onclick*=\"self.jssDetails.location='products.php?xUser=kery&amp;xRand=123';\"]"));

Also, you might want to post every XPaths you have tried, to help us analyse.

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

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.