elementToBeClickable
is used for checking an element is visible and enabled such that you can click it.
ExpectedConditions.elementToBeClickable
returns WebElement
if expected condition is true otherwise it will throw TimeoutException
, It never returns null
.
So if your using ExpectedConditions.elementToBeClickable
to find an element which will always gives you the clickable element, so no need to check for null
condition, you should try as below :-
WebDriverWait wait = new WebDriverWait(Scenario1Test.driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("(//div[@id='brandSlider']/div[1]/div/div/div/img)[50]")));
element.click();
As you are saying element.click()
passes both on link
and label
that's doesn't mean element is not clickable, it means returned element clicked
but may be there is no event performs on element by click action.
Note:- I'm suggesting you always try first to find elements by id
, name
, className
and other locator. if you faced some difficulty to find then use cssSelector
and always give last priority to xpath
locator because it is slower than other locator to locate an element.
Hope it helps you..:)