有疑问。我是硒的新手。我必须访问下拉菜单。但没有classname / id。 该菜单的Xpath是
/html/body/div[1]/aside/section/ul/li[3]/a
进一步下拉是
/html/body/div[1]/aside/section/ul/li[4]/a
如何通过xpath访问下拉菜单。冲了很多。
答案 0 :(得分:0)
我想这https://stackoverflow.com/a/7235199/8204715会帮助你。
主要思想是将一个下拉菜单作为WebElement,然后使用单独的项目进行处理。
答案 1 :(得分:0)
我不知道你真正想要的是什么,但你可以像这样使用下拉:
Select sampleDropDown= new Select(driver.findElement(By.xpath("value")));
sampleDropDown.selectByVisibleText("Values"); //using visible text
sampleDropDown.selectByIndex(1); //using Index
您可以获得完整示例here