Selenium表示元素已“成功”单击,但是实际上并未单击

问题描述 投票:0回答:1

enter image description here

我有一个需要单击继续按钮的场景。即使我在单击功能后给出了打印消息。消息正在打印但按钮没有单击。我尝试了Java脚本执行程序,明确等待(elementtobeclickable),但仍然没有单击。另一种解决方案是。这是我到目前为止尝试过的

    By click_continue= By.xpath("//input[@id='btnWFContinue']");

    if(driver.findElement(click_continue)!=null) {      
    waitVar.until(ExpectedConditions.elementToBeClickable(driver.findElement(click_continue)));
    WebElement ele = driver.findElement(click_continue);
   JavascriptExecutor executor = (JavascriptExecutor)driver;
    executor.executeScript("arguments[0].click();", ele);
    log.info("Clicked on Continue!!!");

 /*
WebElement element = driver.findElement(click_continue);
Actions actions = new Actions(driver);
actions.moveToElement(element).click().build().perform();        
driver.findElement(click_continue).click();    */
   }else {
  log.info("Continue button is not present moving to next step");
 }
java selenium click
1个回答
0
投票
在浏览器中打开所需的页面,然后打开浏览器控制台。同样执行以下代码$(“ input [id ='btnWFContinue']”)。click()或document.getElementById(“ btnWFContinue”)。click()

如果该元素是可点击的,则上述javascript命令必须更改网页。在脚本中也使用相同的内容。其他没有与您的元素相关联的点击事件。

© www.soinside.com 2019 - 2024. All rights reserved.