使用java从组合框selenium驱动程序中选择项目

Esh*_*ama 3 java selenium qa

我尝试通过selenium驱动程序用java从组合框中选择一个项目.但它没有用.

这是我的代码......

combo box list={NIC,NAME,AGE}

driver.findElement(By.xpath("//div[@id='views/div/select']/label")).sendKeys("NIC");

San*_*rma 5

在WebDriver中有单独的Class(Select)可以处理Combo列表.

使用以下逻辑从选择列表字段中选择选项

Select select=new Select(driver.findElement(By.xpath("//div[@id='views/div/select']"));

select.selectByVisibleText("NIC");
or
select.selectByIndex(0);
or
select.selectByValue("value");
Run Code Online (Sandbox Code Playgroud)

有关选择课程的更多信息,请参阅此帖子.