I've got a pretty simple selenium script running on a raspberry pi.
I was having issues with a specific page not loading so I wanted to reduce the timeout on driver.get(url)
to be 15 seconds to hopefully prevent things from hanging. I used this post as a guide on how to set that info. How to set Selenium Python WebDriver default timeout?
I get an odd error stating that I'm not passing a number when I am clearly passing a number
>>> from selenium import webdriver
>>> from pyvirtualdisplay import Display
>>>
>>> display = Display(visible=0, size=(1200, 1200))
>>> display.start()
<Display cmd_param=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '1200x1200x24', ':1009'] cmd=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '1200x1200x24', ':1009'] oserror=None return_code=None stdout="None" stderr="None" timeout_happened=False>
>>> driver = webdriver.Firefox()
>>> driver.set_page_load_timeout(15)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/Projects/yesware_prod/yesware/venv/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 727, in set_page_load_timeout
'pageLoad': int(float(time_to_wait) * 1000)})
File "/home/pi/Projects/yesware_prod/yesware/venv/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 238, in execute
self.error_handler.check_response(response)
File "/home/pi/Projects/yesware_prod/yesware/venv/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Not a Number
I'm not sure what the issue is. Even if I confirm that I'm passing in an integer I'm still getting the error
>>> num_secs = 15
>>> type(num_secs)
<type 'int'>
>>> driver.set_page_load_timeout(num_secs)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/Projects/yesware_prod/yesware/venv/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 727, in set_page_load_timeout
'pageLoad': int(float(time_to_wait) * 1000)})
File "/home/pi/Projects/yesware_prod/yesware/venv/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 238, in execute
self.error_handler.check_response(response)
File "/home/pi/Projects/yesware_prod/yesware/venv/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Not a Number
Here's a link to the github page - https://github.com/SeleniumHQ/selenium/blob/fa24958570432ee6eadaadc9a7fb92e1ee380dfc/py/selenium/webdriver/remote/webdriver.py#L714
EDIT I ended up finding a workaround by using PhantomJS()
rather than Firefox()
. This tutorial is fantastic - How to install PhantomJS for use with Python Selenium on the Raspberry Pi?