![](/img/trans.png)
[英]Unable to click on the submit button with xpath and classname using selenium webdriver
[英]Unable click button by xpath in selenium webdriver
这是我的代码
<button type="button" id="B-New" data-sap-ui="B-New" title="Add New Order" role="button" aria-disabled="false" tabindex="0" class="sapUiBtn sapUiBtnNorm sapUiBtnS sapUiBtnStd">Add</button>
为此, xpath
是"//*[@id='B-New']"
我试图单击该按钮,但无法这样做。
我已经使用了xpath,ID类名已全部使用,但无法单击。 这就是我正在使用的
driver.findElement(By.xpath("//*[@id='B-New']")).click()
请帮助。
我也用过javascript
jse.executeScript("document.getElementById('B-New').click()");
但它也不起作用。
您应该尝试使用WebDriverWait
来等待元素可见,并启用如下所示的单击:-
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement el = wait.until(ExpectedConditions.elementToBeClickable(By.id("B-New")));
el.click();
注意 :-如果此元素在任何frame
,则需要在使用driver.switchTo().frame("frame name or id")
查找并单击该元素之前切换该框架。
希望能帮助到你..:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.