简体   繁体   中英

How to click an element without id inside div without class using Xpath and C#

在此处输入图片说明

I am supposed to click the link (highlighted blue, refer to image above), but LinkText does not work. I also tried using CSSSelector and XPath , but both:

_driver.FindElement(By.CSSSelector("HH3"]")).Click();
_driver.FindElement(By.XPath("div[text()="HH3"]")).Click();

doesn't work. Help?

您尝试过的定位器看起来不正确,您应该尝试使用xpath和文本来定位所需元素,如下所示:-

_driver.FindElement(By.XPath(".//div[text()='HH3']")).Click();

尝试_driver.FindElement(By.XPath("//div[contains(text()='HH3')]")).Click();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM