本文介绍了href元素的Xpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有些人可以帮助我找到
<div class="row 2">
<a href="URL1" class="class 1">display this </a>
</div>
相同的 URL1
被多次使用代码
推荐答案
使用CSS选择器查找元素:
To find your element with a CSS selector :
driver.findElement(By.cssSelector(
"div[class='row 2'] > a[class='class 1'][href$='URL1']"));
使用XPath查找元素:
To find your element with an XPath :
driver.findElement(By.xpath(
"//div[@class='row 2']/a[@class='class 1'][text()='display this ']"));
这篇关于href元素的Xpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!