对于以下代码,可以使用哪些定位器策略在 selenium 中查找元素
Which locator strategies can be used to find the element in selenium for the below code
使用哪个定位器来查找元素年鉴?尝试使用 LinkText 也包括所有其他定位器。好像不行
<a href="#" data-toggle="collapse" data-target="#menu-yearbooks" class="collapsed noRewrite" xpath="1">
Yearbooks
<i class="glyphicon glyphicon-chevron-up"></i>
</a>
使用这个 xpath
//*[contains(text(),'Yearbooks')]
根据 HTML 您只能使用以下 :
LinkText:
Yearbooks
Xpath:
"//a[@class='collapsed noRewrite' and contains(@data-target, 'menu-yearbooks')]"
使用哪个定位器来查找元素年鉴?尝试使用 LinkText 也包括所有其他定位器。好像不行
<a href="#" data-toggle="collapse" data-target="#menu-yearbooks" class="collapsed noRewrite" xpath="1">
Yearbooks
<i class="glyphicon glyphicon-chevron-up"></i>
</a>
使用这个 xpath
//*[contains(text(),'Yearbooks')]
根据 HTML 您只能使用以下
LinkText:
Yearbooks
Xpath:
"//a[@class='collapsed noRewrite' and contains(@data-target, 'menu-yearbooks')]"