2012-11-01 32 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;