无法使用 xpath 获取 bootstrap-dropdown 的 selenium web 驱动程序中的 webelement 文本

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

我想访问服务中的每个 bootstrap 下拉菜单,然后必须 select 一项服务并单击它 参考这个网站,https://mybmtc.karnataka.gov.in/english

我使用这个 XPath

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

这是检查元素代码: 服务

--> --> -->特许服务

您需要将鼠标悬停在服务上,使用下面的 CSS :

a[title='Services']

然后 Select link Chartered Services 使用 link_text.

悬停:

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

然后点击:

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