Error with List <WeElement> - The type List is not generic; it cannot be parameterized with arguments <WebElement>

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Error with List <WeElement> - The type List is not generic; it cannot be parameterized with arguments <WebElement>

Illusion0Reality
This should be pretty basic, but I need help.
List <WebElement> options = driver.findElements(By.tagName("option"));
Error:   The type List is not generic; it cannot be parameterized with arguments <WebElement>

I imported all those things like below:

import java.awt.List;
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.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import com.thoughtworks.selenium.Selenium;

public class we122
{
        public static WebDriver driver = new FirefoxDriver();
        public static Selenium selenium;
        @Test
        public void testUntitled() throws Exception {
                 String valToBeSelected;
          driver.get("" + "file:///C:/Documents%20and%20Settings/Madhuri/Desktop/a.html");
                new Select(driver.findElement(By.name("AllVal"))  ).selectByVisibleText("A");
                driver.findElement(By.name("mt")).sendKeys("mmmmmm");
                Thread.sleep(11111);
                System.out.print("finished");
                driver.close();
              List<WebElement> options = driver.findElements(By.tagName("option"));
                        for (WebElement option : options)
        {
                                if (valToBeSelected.equalsIgnoreCase(option.getText())){
                                        option.click(); }    
        }

        }
}
Reply | Threaded
Open this post in threaded view
|

Re: Error with List <WeElement> - The type List is not generic; it cannot be parameterized with arguments <WebElement>

softwaretestingforum
Administrator
can driver.close()

before List <WebElement> options = driver.findElements(By.tagName("option"));

be an issue?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Error with List <WeElement> - The type List is not generic; it cannot be parameterized with arguments <WebElement>

Illusion0Reality
This post was updated on .
Solution - import java.awt.List;


The issue has nothing to do with driver.close().
I changed the code like below, still got issue.
I am also trying to fix, but did not understand the cause. Any imports / variable declarations ??
Is the syntax correct?

Thread.sleep(11111);
                System.out.print("finished");
              List <WebElement> options = driver.findElements(By.tagName("option"));
                        for (WebElement option : options)
        {
                                if (valToBeSelected.equalsIgnoreCase(option.getText())){
                                        option.click(); }    
        }
                        driver.close();

Reply | Threaded
Open this post in threaded view
|

Re: Error with List <WeElement> - The type List is not generic; it cannot be parameterized with arguments <WebElement>

softwaretestingforum
Administrator
Ok, I just realized -

import java.awt.List

use java.util.List

also to select drop down value by visible text do -

new Select(getDriver().findElement(By.cssSelector("drop down locator"))).selectByVisibleText("drop down value")
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Error with List <WeElement> - The type List is not generic; it cannot be parameterized with arguments <WebElement>

Illusion0Reality
Thanks for the help !