简体   繁体   English

无法单击Selenium中的按钮

[英]Not able to click a button in Selenium

I am not able to click a button in my script. 我无法单击脚本中的按钮。 The HTML for the button is below. 该按钮的HTML如下。 Please have a look and guide me. 请看看并指导我。

I am using Java (Webdriver 4). 我正在使用Java(Webdriver 4)。

<td width="55" valign="baseline" align="center">
<input class="Button" width="55" type="button" align="bottom" onclick="changeTab(2)" value=" Next ">
</td>

Very common issue with this is the wait or element load time and easiest fix will be to implement some explicit wait and the possible solution is as follows 与此相关的非常普遍的问题是等待或元素加载时间,最简单的解决方法是实施一些显式等待,可能的解决方案如下

By css = By.cssSelector("input.Button[value*='Next']");
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
  .until(ExpectedConditions.presenceOfElementLocated(css);
 myDynamicElement.click();

试试这个代码:

driver.findElement(By.xpath("//input[contains(@value,'Next')]")).click();

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

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