I’m using Selenium RC to write test cases for a website that’s at least partially dynamically generated or otherwise dependent on a database. I’d like to be able to tell my Python program making calls to Selenium to do string operations on the target of a specific link, but I can’t be sure what the target (the href=” field) will be at “compile time” (or, well, whatever the Python equivalent is. Can someone help me out there?).
Now, I am sure what the xpath of that link is going to be; “//table[@id=’search-results’]/tbody/tr[2]/td[3]/a/img” . And I am running Selenium, which has an eval() function (the root of all evil) that runs arbitrary lines of javascript. Is there any way I can get the target of this link from the xpath and Selenium, or do I have to find some way to download the entire page source (how do I do this? There was supposed to be a Selenium command to download the entire page source, but I got an “element doesn’t exist” error when I tried running it) and then break out regexes to mess with the entire page source?
I think you can do this using the
get_attributePython method here: http://code.google.com/p/selenium/source/browse/trunk/py/selenium/selenium.py#1343The call would look something like: