selenium可以处理
select/option在一个很好的和方便的方式。
这是通过可见文本选择选项的方法(java中的示例):
Select select = new Select(driver.findElement(By.id("groupSelect")));select.selectByVisibleText('First value');如果您仍然想要基于xpath的解决方案,则可以检查选项
value和
text:
By.xpath("//select[@id='groupSelect']/option[@value='data' and . = 'First value']")或按索引获取:
By.xpath("//select[@id='groupSelect']/option[1]")或者您可以同时检查两者。



