Not able to click on button in java selenium?

后端 未结 2 1684
离开以前
离开以前 2021-01-22 22:36

HTML code:

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-22 23:22

    Executing a click via webdriver has sometime unexpected behaviors.If its not working then alternate way JavascriptExecutor class to do this. Its always preferable to use click() method of the WebElement.

    WebElement element = driver.findElement(By.cssSelector(".btn.btn-main.dropdown-toggle"));
    JavascriptExecutor executor = (JavascriptExecutor)driver;
    executor.executeScript("arguments[0].click();", element);
    

提交回复
热议问题