package com.test.utitlity;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
public class selectDropdown extends globalVariables {
public static void select(String locator, int indexValue) {
Select select= new Select(common.getObject(locator));
//select.selectByValue("selectValue");
System.out.println(indexValue);
select.selectByIndex(indexValue);
}
}
单击下拉列表但未选择选项..下拉列表为空..如何解决此问题?但是当我运行调试模式时,它正在按预期工作。添加了等待条件,但获得了IllegalStateException ..
答案 0 :(得分:0)
您可以尝试以下方法,让我知道结果是什么。
WebDriverWait Test_Wait = new WebDriverWait(driver, 10);
WebElement Drop_down = Test_Wait.until(ExpectedConditions.elementToBeClickable(common.getObject(locator)));
List<WebElement> lst2 = Drop_down.findElements(By.xpath(".//option[contains(text(),'Your_Option_Text')]"));
for (WebElement option : lst2)
{
if (!option.isSelected())
{
option.click();
}
}