2012-11-01 35 views
0

我想模拟一个测试用例,我必须从multipleselect框中选择多个选项。我可以使用select来做到这一点。不过,当我实例化选择时,我正在收到跟随错误。无法实例化类型在selenium webdriver中选择

“无法实例的类型选择”

我的代码是:

import java.awt.List; 
import java.util.ArrayList; 

import junit.framework.Assert; 

import org.apache.bcel.generic.Select; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.support.ui.ExpectedCondition; 
import org.openqa.selenium.support.ui.WebDriverWait; 

public class SeleniumFormTesting { 
//piece of code to open the browser in firefox 

Select selectBox = new Select(driver.findElement(By 
      .cssSelector("select#id_contact"))); 
//in above select statement the error comes 

} 

有人可以请帮我摆脱这个问题

回答

11

使用Select导入包菜系。通过导入Select支持包

import org.openqa.selenium.support.ui.Select;

+2

感谢您的答复,现在错误消失。再次感谢。 – user443208

+0

谢谢!我也有同样的奇怪问题。 – Alam

1

搜索:您可以通过将其导入到你的项目

import org.openqa.selenium.support.ui.Select;