Web驱动程序Selenium找不到元素
本文关键字:元素 找不到 Selenium 驱动程序 Web | 更新日期: 2023-09-27 18:24:01
我有个问题,我写了测试自动化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']"));
你可以在这里阅读更多关于它的信息。