0

I've just started using python and Selenium today so in at the deep end a little.

So far I've used the documentation to get a python script to load google, search for something and then take a screenshot of the results.

What I want is to be able to load a website, navigate to certain elements and take screenshots of various pages. I'm struggling to find documentation for navigation however.

Could someone point me towards (or post an answer with) examples/explanation of find_element and what you can actually find, and also how to open elements once found. The documentation for lots of what I wanted is still under development :(

I've been looking through the WebDriver docs on googlecode at the kind of methods I thought I needed but it seems they are all part of the private API so what alternatives are there? I keep seeing this on everything;

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Found a great example of Action_Chains on here; https://stackoverflow.com/a/8261754/1199464

Community
  • 1
  • 1
markwalker_
  • 12,078
  • 7
  • 62
  • 99
  • I've found an decent example of action_chains which looks like it'll help here [link](http://stackoverflow.com/questions/8252558/is-there-a-way-to-perform-a-mouseover-hover-over-an-element-using-selenium-and) – markwalker_ Mar 01 '12 at 11:00

3 Answers3

1

You can take a look at the basics there:

The full documentation and up-to-date documentation:

p0deje
  • 3,903
  • 1
  • 26
  • 37
  • Yeah thanks I've been looking through everything I can find, most recently this [link](http://selenium-python.readthedocs.org/en/latest/locating-elements.html). I've still not found how to click a link once I've found it though :( – markwalker_ Mar 01 '12 at 10:23
  • Take a look at WebElement methods http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver_remote/selenium.webdriver.remote.webelement.html?highlight=webelement#selenium.webdriver.remote.webelement.WebElement – p0deje Mar 01 '12 at 11:07
  • Thanks, I just found Action_Chains but thats obviously got the same click type methods in the same class as the find methods I'm using which saves an import :) – markwalker_ Mar 01 '12 at 11:10
1

While the selenium documentation is not in a particularly good order, I feel like everything is there.

You could e.g. start here: http://code.google.com/p/selenium/wiki/FurtherResources xpath seems a good choice for finding elements.

Also this page seems to contain what you need: http://seleniumhq.org/docs/03_webdriver.html#commands-and-operation

edit: I found this and it should contain what you need: http://selenium.googlecode.com/svn/trunk/docs/api/py/api.html (sry p0deje, I didnt see that you already posted that last link...)

joidegn
  • 1,078
  • 9
  • 19
  • Yeah I've now found XPATH & it seems like a powerful & useful method. And I've found a lot on finding input elements like forms and how to send text and submit, but I can't find things like how you click a link once you've found it. – markwalker_ Mar 01 '12 at 10:22
  • That commands & operation page looks like I can perhaps use that switchTo & just figure out the python to implement. Thanks – markwalker_ Mar 01 '12 at 10:28
0

Good links, but using XPATH for locators is strongly discouraged (too brittle). Use ID or name, or CSS if you cannot.

Few links to best practices: