Java 如何从包含部分文本的下拉列表中选择选项
下拉列表的id=“rw_520631” 我要从下拉列表中选择的值为=“自动化RW(0/6)” 现在这里的“自动化RW”是静态的,但是“(0/6)”可以更改。Java 如何从包含部分文本的下拉列表中选择选项,java,selenium-webdriver,automation,Java,Selenium Webdriver,Automation,下拉列表的id=“rw_520631” 我要从下拉列表中选择的值为=“自动化RW(0/6)” 现在这里的“自动化RW”是静态的,但是“(0/6)”可以更改。 如何使用JAVA中的selenium webdriver选择此选项此问题已在此处得到回答- 以下是答案的片段: List <WebElements> optionsInnerText= driver.findElements(By.tagName("option")); for(WebElement text: option
如何使用JAVA中的selenium webdriver选择此选项此问题已在此处得到回答- 以下是答案的片段:
List <WebElements> optionsInnerText= driver.findElements(By.tagName("option"));
for(WebElement text: optionsInnerText){
String textContent = text.getAttribute("textContent");
if(textContent.toLowerCase.contains(expectedText.toLowerCase))
select.selectByPartOfVisibleText(expectedText);
}
列出选项InnerText=driver.findElements(按.tagName(“选项”));
用于(WebElement文本:选项InnerText){
字符串textContent=text.getAttribute(“textContent”);
if(textContent.toLowerCase.contains(expectedText.toLowerCase))
select.selectByPartOfVisibleText(expectedText);
}
请将您的代码添加到相关的html中