Home > OS >  Explicit waits best combinations for click
Explicit waits best combinations for click

Time:11-16

I'm wondering what combination of explicit waits will be the best for click method. Currently, I'm using only:

ExpectedConditions.visibilityOf

And I thought it will be better to replace it or combine (add two) with:

ExpectedConditions.elementToBeClickable

Would it be a good practice here?

CodePudding user response:

It's not this method is better or this.
There are different elements on different web pages. Some elements are not visible at all so only presenceOf expected conditions can be applied on such elements, some are visible but not clickable and some are visible and clickable.
So, if you want to extract a text from element you probably will use visibilityOf expected conditions but if you want to click some element elementToBeClickable should be used.
Just for additional information: elementToBeClickable Selenium method is internally contains ExpectedConditions.visibilityOf and isEnabled.
So, elementToBeClickable is actually means element is visible and enabled.
This also means you do not need to combine ExpectedConditions.visibilityOf and ExpectedConditions.elementToBeClickable if you want to click the element. ExpectedConditions.elementToBeClickable is enough since it internally contains ExpectedConditions.visibilityOf as described.

  • Related