Reputation: 174
I'm just starting to play with UDOO (a single board computer similar to Raspberry Pi). I have some code that I'm trying to get some test code working on it without any luck.
The following code works on my Ubuntu laptop.
#!/usr/bin/env python
import timeit
def test():
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from pyvirtualdisplay import Display
import time
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Firefox()
browser.get('http://www.google.com')
q = browser.find_element_by_name('q')
q.send_keys("python")
q.send_keys(Keys.ENTER)
time.sleep(4)
results = browser.find_elements_by_class_name('g')
for result in results:
try:
print '-' * 80
print result.text
except:
pass
browser.close()
display.stop()
return 0
print(timeit.timeit("test()", setup="from __main__ import test", number=10))
However when I run the same file on the UDOO board, it get the following error message:
Traceback (most recent call last):
File "./selenium_test.py", line 36, in <module>
test()
File "./selenium_test.py", line 16, in test
browser = webdriver.Firefox()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
self.binary, timeout),
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 41, in __init__
PORT = utils.free_port()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/utils.py", line 27, in free_port
free_socket.bind(('127.0.0.1', 0))
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 99] Cannot assign requested address
I did some testing on my laptop and under normal conditions, free_port() will return an open port on the system very quickly. When I execute the same tests on the UDOO board, it crashes every time.
This is a similar problem as this post (PyCharm unable to connect to GhostDriver) which ended up being an environment variable issue within PyCharm. Unfortunately the solution in that post doesn't apply to this situation because I'm executing the script from the command line.
Laptop (successful environment): Dell Latitude E6520, Ubuntu 12.04, Intel Core i5
Development Board (unsuccessful environment): UDOO Quad, Debian 7 (wheezy), ARM Processor
Any ideas? Do you need any additional information to help diagnose the problem?
Thanks, Ben
Upvotes: 1
Views: 3320
Reputation: 174
I continued playing around after posting this question. It turns out that I couldn't ping 127.0.0.1 either so I looked into my loopback device.
I added:
auto lo
iface lo inet loopback
to /etc/network/interfaces and ran:
sudo ifup lo
to initialize my loopback device. It runs great now.
Upvotes: 4