using xpath to tell selenium where to click?
I'm new to all of this but I've learned a few things about python not long time ago, could you help me specify the correct the XPath for selenium to click?
I've tried this way, but didn't work, obviously :(
self.selenium.click("xpath=//html/body/div/div/div/div[4]/ul/li[3]/a")
If you're wandering where did i get that ugly XPath, it's from Firebug's copy XPath option.
I think that the HTML snippet is as long as hell 开发者_开发技巧so i couldn't do more than this:
<html>
<body>
<div id="outer_wrapper">
<div id="container">
<div id="header">
<div id="menunav">
<ul>
<li><a title="Login page" href="[dest]">Login</a></li>
<li><a title="" href="[dest]">Sitemap</a></li>
**<li><a title="" href="[dest]">Administration</a></li>**
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
Below are a few example locators you could use to click the Administration
link (based on your XPath and HTML snippet). The correct Selenium command is click
.
link=Administration
css=a:contains(Administration)
css=#menunav a:nth-child(3)
xpath=id('menunav')/descendant::a[3]
//a[text()='Administration']
//a[contains(text(), 'Administration')]
I hope this points you in the right direction.
精彩评论