Skip to content
Advertisement

Expected condition failed: waiting for element to be clickable: By.xpath: //*[@id=”documentation”]/div/div[2]/div/button

I am trying without success to click on a particular button using SELENIUM & JAVA but i am getting this error message:

JavaScript

That button has this:

JavaScript

The XPATH is:

JavaScript

I did this:

JavaScript

What am i doing wrong in here?

Advertisement

Answer

If you use the xpath:

JavaScript

Should work.

Why this happened?

The problem is that you were using the xpath:

JavaScript

With that xpath what you are doing is:

  1. Locating an element with id="documentation"
  2. Then go to the first div child of that element
  3. Then go to second div child of the previous div
  4. Then go to the first div child of the previous div
  5. Then go to the button

As you can see your final element (The button) is depending on several other parent elements to be located. Once one of those parent elements changes, your xpath is not valid anymore.

Is much better to locate your xpath based on the properties of your element itself, not on the elements that surround it.

In this case I used the text of the element.

I don’t know if it is possible or not, but if it is possible, a good idea is to talk with developers for using ids for all the elements you will use with your automation. This is a team work!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement