I have a small test python script that uses Selenium and PhantomJS. Python version is 2.7 and PhantomJS is 1.9.2. I later plan to use this with BeautifulSoup for accessing a financial website.
My python script looks like this -
from selenium import webdriver
phantomJSPath = "C:\my working dir\\Lib\phantomjs.exe"
browser = webdriver.PhantomJS(executable_path=phantomJSPath)
After executing I get the below error -
File "C:\my working dir\Test.py", line 32, in run
browser = webdriver.PhantomJS(executable_path=phantomJSPath)
File "C:\Python27\lib\site- packages\selenium\webdriver\phantomjs\webdriver.py", line 56, in __init__
desired_capabilities=desired_capabilities)
File "C:\Python27\lib\site- packages\selenium\webdriver\remote\webdriver.py", line 87, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 136, in start_session
'desiredCapabilities': desired_capabilities,
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 196, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 102, in check_response
value = json.loads(value_json)
File "C:\Python27\lib\json\__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "C:\Python27\lib\json\decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Would anyone know why I am getting this error?
Sorry to answer my own bounty, but for those who might possibly run into similar issues: the http_proxy environment variable does not play well with phantomjs and selenium. I removed it and all worked as it should have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With