Selenium webdriver : <WebElement> Itérateur ne peut pas être résolu à un type

Mon Problème en bref :

Par le biais de Mon sélénium web pilote, maintenant, je suis en train de tester une liste d'éléments dans une zone de liste , Tout en utilisant le code suivant, j'obtiens l'erreur

Tests De Configuration :

  • Mozilla firefox
  • Eclipse Indigo
  • Selenium Webdriver 2

Scénario qui, je l'ai testé :

  1. Site ouvert
  2. De sélectionner et d'afficher la liste des éléments de la zone de
  3. Écrire dans la console

Mon erreur :

java.lang.Erreur: non résolus des problèmes de compilation: Le type de Liste n'est pas générique; il ne peut pas être paramétrée avec des arguments Itérateur ne peut pas être résolu à un type

Mon Code :

package com.example.tests;
import java.util.Iterator;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.WebElement;
import org.openqa.jetty.html.List;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import com.browsersetup.test.BrowserSetup;
import org.testng.*;
import org.testng.annotations.*;
import org.testng.annotations.Test;
@SuppressWarnings("unused")
public class sample2 extends BrowserSetup{
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@BeforeClass
public void setUp() throws Exception {
driver = new OperaDriver();
baseUrl = "http://www.ebay.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
System.out.println("Browser = " + driver);
System.out.println("Base URL = " + baseUrl);
}
@Test
public void testUntitled() throws Exception {
driver.get(baseUrl + "/");
Thread.sleep(10000);
WebElement element = driver.findElement(By.name("_sacat"));
Select dd= new Select(element);
List<WebElement> allOptions= dd.getOptions();
//To go through the list, we can use an Iterator. 
//Iterator should be of the same type as the List
//which is WebElement in this case.
Iterator<WebElement> it = allOptions.iterator();
//Using while loop, we can iterate till the List has 
//a next WebElement [hasNext() is true]
//number of items in the list
System.out.println(allOptions.size());
while(it.hasNext()){
//When you say it.next(), it points to a particular
//WebElement in the List.
WebElement el = it.next();
//Check for the required element by Text and click it
if(el.getText().equals("mango")){
System.out.println(el.getAttribute("value"));
el.click();
}
}
@AfterClass
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}

Je ne sais pas où ça s'est mal passé,guide-moi où ça s'est mal passé

merci d'avance

OriginalL'auteur Valamburi Nadhan | 2013-07-16