Selenium与Java如何处理组合框
我想从组合框中选择一个值。 我试过这个:Selenium与Java如何处理组合框,java,selenium,Java,Selenium,我想从组合框中选择一个值。 我试过这个: @Test(enabled = true) public void hierarchyLegendArea() throws Exception { setUp(Constants.BASE_URL_NAME, "chrome"); selenium.setSpeed("1500"); selenium.open(Constants.OPEN_NMA_TEMPLATE_DIR); s
@Test(enabled = true)
public void hierarchyLegendArea() throws Exception {
setUp(Constants.BASE_URL_NAME, "chrome");
selenium.setSpeed("1500");
selenium.open(Constants.OPEN_NMA_TEMPLATE_DIR);
selenium.windowMaximize();
Thread.sleep(15000);
String comboBoxId = "//*[@id=\"contentTopBarCombobox\"]/div/div[1]/div[2]";
String valueInSideComboBoxId ="combo_box_values_cachable";
selenium.click(comboBoxId);
Thread.sleep(1000);
selenium.click(valueInSideComboBoxId);
}
但这并不奏效。
有人知道如何从组合框中选择值吗
当我尝试添加驱动变量时,eclips要求我声明它
WebDriver driver = new FirefoxDriver();
Select dropDown = new Select(driver.findElement(By.id("contentTopBarCombobox")));
dropDown.selectByValue("yourValue");
或
你需要导入这个
import org.openqa.selenium.WebDriver;
在类中添加驱动程序变量时。如果使用selenium rc(旧的),则使用selenium。选择而不是selenium。单击。请参阅
selenium.select("yourComboName", "label=yourValue");
相关什么是驱动程序?我以前从未使用过它,如何声明它?@mohammad我更喜欢Firefox,但你可以使用ie或chrome。我编辑了我的问题,以便更清楚地说明什么是驱动程序variable@mohammad驱动程序是org.openqa.selenium.WebDriver,请参阅
selenium.select("yourComboName", "label=yourValue");