Select class cannot be resolved to a type

193 views
Skip to first unread message

shaimaa kelany

unread,
May 13, 2020, 2:32:52 PM5/13/20
to Selenium Users
Hello,

i am a selenium user Beginner and i face this problem when trying to use a "Select class",
this is my code,

public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Admin\\eclipse-workspace\\New_Project\\bin\\chromedriver_win32 (2)\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.get("https://facebook.com");
    WebElement day = driver.findElement(By.id("day"));
    Select dayvalue = new Select (day);
    dayvalue.selectByIndex(23);

and the error appear on select "Select cannot be resolved to a type"

so please, if you have any suggestion, something missed or what, please inform me,
thank you.

Hanumantha Reddy

unread,
May 13, 2020, 3:11:07 PM5/13/20
to Selenium Users
Hi Shaimaa,

You have to import the package "org.openqa.selenium.support.ui" where Select class in defined. If you have generated "Select" class by mistake delete and import "org.openqa.selenium.support.ui" package, it should work.

For more details on how to use Select class, watch the below video.

Thanks
Hanumantha Reddy

Ripon Al Wasim

unread,
May 13, 2020, 3:29:53 PM5/13/20
to seleniu...@googlegroups.com
Hi shaimaa kelany,

Actually what do you want to select? As I have understood you want to select 23 from 1st portion of Birthday, am I right?

br,
Ripon

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/5f2a1404-a6d3-4030-9088-60bb09d0d8a8%40googlegroups.com.

Ripon Al Wasim

unread,
May 13, 2020, 3:46:56 PM5/13/20
to seleniu...@googlegroups.com
Hi Shaimaa,

You can try the following code:

    System.setProperty("webdriver.chrome.driver", "C:\\Users\\Admin\\eclipse-workspace\\New_Project\\bin\\chromedriver_win32 (2)\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.get("https://www.facebook.com/");
    WebElement dropdown = driver.findElement(By.id("day"));
    dropdown.findElement(By.xpath("//option[. = '23']")).click();

On Thu, May 14, 2020 at 12:32 AM shaimaa kelany <shim...@gmail.com> wrote:
--

shaimaa kelany

unread,
May 14, 2020, 8:00:22 AM5/14/20
to Selenium Users
Really thanks for answer I already imported it and it works

Akula Bhaskar

unread,
May 14, 2020, 11:07:59 AM5/14/20
to seleniu...@googlegroups.com



Hey shaimma ,

I have copied pasted your code it worked fine for me.
image.png





--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/5f2a1404-a6d3-4030-9088-60bb09d0d8a8%40googlegroups.com.


--

Best Regards
A Bhaskar Rao
07799870508
Reply all
Reply to author
Forward
0 new messages