-1

I have tried below code :

driver.findElement(By.xpath("//*[@id='content']/div[2]/div/div[5]/div/div/res-view-activity/div/div[1]/a[2]")).click();

This works when using Firefox, but does not work when using Chrome. I am using chrome 2.35.

  • Please share more details like HTML and Exception. – Sagar007 Feb 26 '18 at 4:59
  • Try with different locator type to locate your WebElement. Post your HTML code to figure out the suitable XPath or CssSelector. – Bharat Mane Feb 26 '18 at 6:58
  • What is the xpath of the element in Chrome? (Also, if you are automating an application that your team/company is developing, have the developers add unique labels to the elements you need to use for your tests, so you don't have to use detailed xpath which might change when any changes to the page are made - and break your tests) – Marit Mar 4 '18 at 6:59
1

You can try with Action class or Java script method to click element,

Actions action = new Actions(driver);
action.moveToElement("Element name").click().perform();

OR

js.executeScript("arguments[0].click();", "Element name");

Please use Relative xpath instead of Absolute path.

1

Update the chrome driver version to 2.39 and also update the chrome browser version to 65.0. Then try running this will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.