无法在selenium webdriver中实例化类型Select

use*_*208 1 selenium-webdriver

我试图模拟一个测试用例,我必须从多选框中选择多个选项.我可以使用select来做到这一点.但是,一旦我实例化选择,我就会得到以下错误.

"无法实例化类型选择"

我的代码是:

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

}
Run Code Online (Sandbox Code Playgroud)

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

Ioa*_*oan 12

尝试使用Select导入包.您可以使用以下方法将其导入项目:

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

  • 谢谢你的回复,现在错误消失了.再次感谢. (2认同)