Testing in two different python virtualenv and one system wide install
Selenium has the following problem. Selenium can browse to multiple test
sites with no problem but in each case fails with errors when performing
browser.page_source
Browser: Firefox Quantum 61.0.1 64bit
Selenium version: 3.13.0 and 3.12.0
Web driver: v0.21.0 linux 64
installed system wide at /usr/local/bin/geckodriver
installed virtualenv at etlibs/bin/geckodriver
installed virtualenv at etlibs/selenium/webdriver/firefox/amd64/geckodriver
OS: Ubuntu 16.04.04 LTS, codename: Xenial
Desktop: Mate 1.12.1
Problem:
Browses succesfuly each test to web site, for example
https://sec.gov. But
the python program fails with errors each time while performing
browser.page_source
Code
########################################################################
#!/usr/bin/env python
import time
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('
https://www.sec.gov/')
time.sleep(15)
this_html = browser.page_source
print this_html
########################################################################
Error message when failing browser.page_source
########################################################################
james@james-Noir-et:~/Documents/no_env$ python test-selenium.py
Traceback (most recent call last):
File "test-selenium.py", line 9, in <module>
this_html = browser.page_source
File "/home/james/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 678, in page_source
return self.execute(Command.GET_PAGE_SOURCE)['value']
File "/home/james/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 318, in execute
response = self.command_executor.execute(driver_command, params)
File "/home/james/.local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 472, in execute
return self._request(command_info[0], url, body=data)
File "/home/james/.local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 496, in _request
resp = self._conn.getresponse()
File "/usr/lib/python2.7/httplib.py", line 1136, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 417, in _read_status
raise BadStatusLine(line)
httplib.BadStatusLine: ''
james@james-Noir-et:~/Documents/no_env$
########################################################################
I've tried a number of things except a different browser. Is anyone
have success using Firefox Quantum 61.0.1.64bit with Selenium browser.page_source?
Is this code OK?
Thanks in advance for any help.