When I try to run this code, I am getting an error stating that the element cannot be found, no matter what element I try to find, this is occurring. How do I get this to work?
!/usr/local/bin/python2.7
from selenium import webdriver from pyvirtualdisplay import Display import time
display = Display(visible=0, size=(800, 600)) display.start()
url = "http://antlr.org/"
for retry in range(3): try: browser = webdriver.Firefox() break except: time.sleep(3)
time.sleep(3) source = browser.find_element_by_xpath('//*[@id="whatis"]/p') print source source = source.text.strip()
print source
browser.quit() display.stop()