Open rain1024 opened 10 years ago
<html>
<head></head>
<body>
<ul class="list-host">
<li><a id="target1">Link 1</a></li>
<li><a id="target2">Link 2</a></li>
<li><a id="target3">Link 3</a></li>
<li><a id="target4">Link 4</a></li>
<li><a id="target5">Link 5</a></li>
</ul>
</body>
</html>
# selct by class
$ //*[contains(@class, 'list-host')]
<ul class="list-host">...</ul>
# XPATH start from 1
$ xpath=id("list-host")/li[0]/a
Not found
$ xpath=id("list-host")/li[1]/a
John
$ xpath=id("list-host")/li[2]/a
Peter
$ //a[text()="Link 1"]
<a id="target1">Link 1</a>
Selenium
Install