When I'm trying to get the Dropdown options I am getting an Exception.
Exception
org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "div"
Source Code
driver.findElement(By.xpath("(//a[@class='navbar-nav-link dropdown-toggle'])[1]")).click();
Select drp = new Select (driver.findElement(By.xpath("//div[@class='dropdown-menu show']")));
List<WebElement> opt = drp.getOptions();
for (WebElement we : opt) {
String name = we.getText();
HTML Code
<a href="#" class="navbar-nav-link dropdown-toggle" data-toggle="dropdown" aria-expanded="true"><i class="fa fa-paper-plane"></i> <span>Flight</span></a>
<div class="dropdown-menu show">
<a href="AirHistory" class="dropdown-item"><i class="fa fa-history"></i> <span>History Booking</span> </a>
<a href="AirRetrievePNR" class="dropdown-item"><i class="fa fa-download"></i> <span>Import PNR</span> </a>
<a href="AirReschedule" class="dropdown-item" style="display:none"><i class="fa fa-exchange"></i> <span>Online ReIssue</span> </a>
</div>
I can't able to Select or Access the Dropdown...
Help me to get out of this..!!
--
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/b1bc8d54-2868-411d-9da1-a2c78902b0c8%40googlegroups.com.
org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "div"
--
Can u share the link of the webpage?
Are u trying to access all the drop-down list values and print them?
Thanks,
Mrinmoy