按钮不点击 - 使用java的Selenium Web Driver

时间:2014-04-16 05:26:21

标签: java html selenium selenium-webdriver

请找到以下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),单击Save按钮(“btnSaveUserProfile”)

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

但在执行期间没有点击没有发生相同的错误,没有点击操作的情况下传递了案例

请参阅html代码并提出解决此问题的建议

2 个答案:

答案 0 :(得分:0)

尝试使用javascriptexecutor

执行点击操作
    ((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", driver.findElement(By.id("btnSaveUserProfile")));

答案 1 :(得分:0)

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