简体   繁体   中英

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?

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);

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM