我尝试select()
在我的代码中使用该方法,但 Eclipse 显示错误。是select()
Selenium 的内置方法吗?我不明白。
select(driver2.findElement(By.xpath("//*@id='webLossReport.contact.address.state']")),index=i);
Eclipse 说"The method select(WebElement, int) is undefined for the type entry"
,它给了我一个在这个类中创建方法的选项。
请让我知道其他人如何使用它。我的要求是“根据索引号选择列表值”
更新:按要求发布的代码,
WebElement LSD = driver2.findElement(By.xpath("//select[@id='webLossReport.lossInformation.locationOfLoss.state']"));
List <WebElement> LLS = LossStateDropdown.findElements(By.tagName("option"));
int i= LLS.size();
select(driver2.findElement(By.xpath("//*@id='webLossReport.contact.address.state']")),index=i);