[英]Selecting radio button with dynamic id in java selenium
如何在java selenium webdriver中選擇具有附加動態ID的單選按鈕。 我沒有能力事先確定附加的數字。 所以我需要一種方法來選擇通過部分匹配的文本而忽略最后一個數字。
id=edit-emergency-notification-status-existing-message-7
!在此屏幕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.