I try to find the button by using two way. The first by the xpath directly which is working. But the second way is not working. after using the click() function nothing happen and no error.
First way:
By.xpath(".//*[@id='app:viewAppInsideConfirm:confirmInside:j_id300']").click()
Second way:
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>
BTW:
I try to use xpath to find different items, I got:
Use 'sumbit' as key word can find it, but same as the By.className("iceCmdBtn") Find but with click() no action...
String xpathLocater = ".//*[@type='submit']";
driver.findElement(By.xpath(xpathLocater)).click();
For the ' Yes ' , I got error to find the element...
String xpathLocater = ".//*[@value=' Yes ']"; driver.findElement(By.xpath(xpathLocater)).click();
Guys!!!
It have another button:
So I guess I need use FindElements
假设示例中id
的动态部分为300
,则可以使用starts-with()
进行部分检查:
By.xpath(".//input[starts-with(@id, 'app:viewAppInsideConfirm:confirmInside:') and @class='iceCmdBtn']").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.