繁体   English   中英

按钮未单击-使用Java的Selenium Web驱动程序

[英]Button not Clicking - Selenium Web Driver using java

请找到以下HTML代码

<td class=" center-align" style="padding:10px 0 0 0;" colspan="3">
<span data-bind="visible: !editing()" style="display: none;"></span>
<input id="btnSaveUserProfile" class="orange-but" type="button" data-bind="visible: editing, click:$root.btnSaveUserProfile" value="Save" style="">
<input id="lblEditCancel" class="orange-but" type="button" data-bind="click: EditCancel" value="Cancel">
</td>

下面是我的Java代码(Selenium Webdriver),单击“保存”按钮(“ btnSaveUserProfile”)

driver.findElement(By.id("btnSaveUserProfile")).click();

但是在执行过程中未发生未单击的相同错误,案例被传递而没有单击动作

请参考html代码并提出解决方案

尝试使用javascriptexecutor执行点击操作

    ((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", driver.findElement(By.id("btnSaveUserProfile")));
Can you pl try with the below code, i have included wait statement.

WebDriver Driver;  
 WebDriverWait wait =null; 
 public void function()
 {
  wait=new WebDriverWait(Driver,90);
  WebElement buttonclick=wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("btnSaveUserProfile")));
  buttonclick.click();
 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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