Unable to get the text of webelement in selenium web driver for bootstrap-dropdown using xpath

Issue

I want to access each bootstrap dropdown menus in SERVICES and then have to select one service and click on that
refer this website, https://mybmtc.karnataka.gov.in/english

I use this XPath

IList<IWebElement> menus = driver.FindElements(By.XPath(".//*[@id='navbar - default']/div/div[2]/ul/li[2]/a"));

This is the inspect element code:
Services

–> –> –>Chartered Services

Solution

You need to hover on Service, use the below CSS :

a[title='Services']

then Select the link Chartered Services using link_text.

to hover :

Actions builder = new Actions(driver);
Actions hover = builder.MoveToElement(driver.FindElement(By.CssSelector("a[title='Services']
"))).Build().Perform();

and then click :

driver.FindElement(By.LinkText("Chartered Services")).Click();  

Answered By – cruisepandey

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published