HTML代碼元素在我的應用程序中的元素是:無法找到使用硒的webdriver
<select id="pt1:reg2:1:soc1::content" class="x2h" title="" theme="dark" name="pt1:reg2:1:soc1">
每次XPath是得到改變,但我無法找到的元素。
WebElement w1 = driver.findElement(By.xpath(".//select[starts-with(@id, 'pt1') AND contains(@id, ':soc1::content')]"));
Select s = new Select(w1);
s.selectByVisibleText("Commercial");
使用編輯器上方的括號圖標將代碼與文本分開。 – Adder