I have a problem - I am using the selenium (firefox) web driver to open a webpage, click a few links etc. then capture a screenshot.
My script runs fine from the CLI, but when run via a cronjob it is not getting past the first find_element() test. I need to add some debug, or something to help me figure out why it is failing.
Basically, I have to click a 'log in' anchor before going to the login page. The construct of the element is:
<a class="lnk" rel="nofollow" href="/login.jsp?destination=/secure/Dash.jspa">log in</a>
login = driver.find_element(By.LINK_TEXT, "log in").click()
A) Yes. The easiest way to check if an element exists is to simply call
find_element inside a
B) Yes, I always try to identify elements without using their text for 2 reasons:
For the follow up questions, using
try/catch is how you can tell if an element exists or not and good examples of waits can be found here: http://seleniumhq.org/docs/04_webdriver_advanced.html