Sneha
Sneha

Reputation: 11

Error when clicking on element

I am not able to click on an element in selenium web driver getting error:

Cannot click on element (WARNING: The server did not provide any stack trace information)  

This problem is only on IE and everything works fine on Firefox.

I used isDisplayed() function but it's not showing element. Maybe opacity of the element is zero?

Upvotes: 0

Views: 46

Answers (2)

Maciek
Maciek

Reputation: 141

It may be related to fact that object was not loaded yet, you can wait until button is displayed.

WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("id"))).click();

Upvotes: 0

RemcoW
RemcoW

Reputation: 4326

If the element is not visible you cannot click on it through normal ways. You could execute a javascript script to click on it though.

JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);

Upvotes: 1

Related Questions