简体   繁体   中英

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. Please have a look and guide me.

I am using 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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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