0

Example not exact code:

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(45));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id(Element)));
wait.Until(ExpectedConditions.ElementToBeClickable(By.Id(Element)));
driver.FindElement(By.Id(Element)).Click();

And it SOMETIMES simply doesnt click. No errors, nothing, and tests fail at next steps, because i assume element has been clicked. 1/10 of same test runs fail to click.

Afterwards inspecting failed test, webdriver seem to 'highlight' checkbox instead of click. Manually i can obviously see/click it.

Google says it might be because element is not enabled yet at point when driver is clicking but i understand if its clikable its enabled. And if it would be covered by another element due to loading error would be different: 'element is not clickable at point..' and there are no errors.

I really would not want to use explicit waits.

What could cause it ?

1 Answer 1

0

What you could do is to change the browser and/or the selenium server version.

Try few combinations of selenium and the browser driver versions ans see which one is most stable.

If you have issues only in a certain section when clicking the button you could try to add a method to wait for the page to be loaded if needed and add an extra focus on the element before clicking it.

In my case when this started to happen i updated the browser driver version and also the selenium version.

2
  • No, even after experimenting with different webdriver and firefox versions, some clicks still fail, in the same as before way. And on at least 3 different elements. But it's not 1/10, more like 1/100 now, same element is clicked in the same way across multiple tests, yet sometimes click doesnt happen (not in the same tests even!). This is literally driving me insane.
    – George
    Commented Sep 7, 2016 at 9:17
  • Changed to chromedriver/chrome and although i havnt run enough tests to make sure it solves it, seems to work way better.
    – George
    Commented Sep 7, 2016 at 10:07

Your Answer

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

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