0

Have a doubt.I am new for selenium. I have to access the drop down menus.But not having classname/id for it. Xpath of that menu is

/html/body/div[1]/aside/section/ul/li[3]/a 

for further drop down is

/html/body/div[1]/aside/section/ul/li[4]/a 

How can i access the drop down menu.by xpath. Surfed alot.

NarendraR
  • 7,577
  • 10
  • 44
  • 82
  • Can you share the site URL or can add some html code in your questions? – NarendraR Nov 07 '17 at 12:53
  • Possible duplicate of [Selenium WebDriver and DropDown Boxes](https://stackoverflow.com/questions/7232544/selenium-webdriver-and-dropdown-boxes) – MTCoster Nov 07 '17 at 12:59

2 Answers2

0

I guess this https://stackoverflow.com/a/7235199/8204715 will help you.

The main idea is to get a drop-down menu as a WebElement and then work with it as with separate item.

0

I don't know what you actually want but you can use drop down like this:

Select sampleDropDown= new Select(driver.findElement(By.xpath("value")));
        sampleDropDown.selectByVisibleText("Values");  //using visible text
        sampleDropDown.selectByIndex(1); //using Index

You can get full example here

iamsankalp89
  • 4,607
  • 2
  • 15
  • 36