Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我尝试使用 java. 通过 selenium 驱动程序从组合框中选择一个项目。但它没有用。
这是我的代码...
combo box list={NIC,NAME,AGE}
driver.findElement(By.xpath("//div[@id='views/div/select']/label")).sendKeys("NIC");
在 WebDriver 中有单独的类 ( Select ) 来处理组合列表。
使用以下逻辑从选择列表字段中选择选项
Select select=new Select(driver.findElement(By.xpath("//div[@id='views/div/select']")); select.selectByVisibleText("NIC"); or select.selectByIndex(0); or select.selectByValue("value");
有关 Select 类的更多信息,请参阅此帖子。