![](/img/trans.png)
[英]CssSelector cannot find element by Id (selenium webdriver C#)
[英]Webdriver Selenium c# - cannot find element
我有一個問題,我寫了自動化測試C#。 在我的應用程序中,我處於菜單位置:
<a href="/op/va">
<i class="fa fa-fw fa-child"></i>
<div class="sidebar__label">I read</div> </a>
我想單擊該位置“我閱讀”,但我不知道如何搜索該元素。
您可以通過多種方式使用元素:
//class name
driver.FindElement(By.ClassName("sidebar__label"));
//xpath using class name
driver.FindElement(By.Xpath(".//*[@class='sidebar__label']"));
//xpath using text
driver.FindElement(By.Xpath(".//*[text()='I read']"));
您可以在此處了解更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.