rain1024 / gVim-Pathogen

My Coding Life
http://rain1024.github.io/gVim-Pathogen
2 stars 0 forks source link

Web Browser Automation #30

Open rain1024 opened 10 years ago

rain1024 commented 10 years ago

Selenium

install firefox install selenium add-ons

rain1024 commented 10 years ago

XPATH

Tools

HTML Test Document

<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>

Select by id, class

# 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 

Select base on value

$ //a[text()="Link 1"]
<a id="target1">Link 1</a>