[英]Selecting radio button with dynamic id in java selenium
How do I select a radio button in java selenium webdriver that has an appended dynamic id. 如何在java selenium webdriver中选择具有附加动态ID的单选按钮。 I don't have the ability to determine before hand the number that is appended.
我没有能力事先确定附加的数字。 So I need a way to select via partially matching text while ignoring that last number.
所以我需要一种方法来选择通过部分匹配的文本而忽略最后一个数字。
id=edit-emergency-notification-status-existing-message-7
!"7" is generated with each new item created in this screen 1 !在此屏幕1中创建的每个新项目都会生成“7”
在starts-with()
的帮助下通过xpath获取它:
//*[starts-with(@id, "edit-emergency-notification-status-existing-message-")]
尝试CSS选择器并使用野生字符开头(^)
driver.findElement(By.cssSelector("input[id^='edit-emergency-notification-status-existing-message']"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.