[英]Unable to click on the submit button with xpath and classname using selenium webdriver
[英]selenium: find the right button but fail to click by using className
我尝试通过两种方式找到按钮。 第一个由xpath直接起作用。 但是第二种方法不起作用。 使用click()函数后,没有任何反应,也没有错误。
第一种方式:
By.xpath(".//*[@id='app:viewAppInsideConfirm:confirmInside:j_id300']").click()
第二种方式:
By.className("iceCmdBtn").click()
的HTML:
<input id="app:viewAppInsideConfirm:confirmInside:j_id300" class="iceCmdBtn" type="submit" value=" Yes " onfocus="setFocus(this.id);" onclick="parent.JSsessionTimeOut.resetSessionTimeout();iceSubmit(form,this,event);return false;" onblur="setFocus('');" name="app:viewAppInsideConfirm:confirmInside:j_id300"></input>
顺便说一句:
我尝试使用xpath查找不同的项目,我得到了:
使用“ sumbit”作为关键字可以找到它,但是与By.className(“ iceCmdBtn”)Find相同,但是使用click()则没有任何操作...
String xpathLocater = ".//*[@type='submit']";
driver.findElement(By.xpath(xpathLocater)).click();
对于'是',我找不到元素...
字符串xpathLocater =“ .//*[@value='是']”; driver.findElement(By.xpath(xpathLocater))。click();
伙计们!
它有另一个按钮:
所以我想我需要使用FindElements
假设示例中id
的动态部分为300
,则可以使用starts-with()
进行部分检查:
By.xpath(".//input[starts-with(@id, 'app:viewAppInsideConfirm:confirmInside:') and @class='iceCmdBtn']").click()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.