when trying to launch firefox from Pycharm IDE or from Terminal with the next simple script:
from selenium import webdriver
a = webdriver.Firefox(firefox_binary='/usr/local/bin/geckodriver')
no browser session is opened and i'm getting this issue:
Traceback (most recent call last):
File "/Users/avihaiezaguy/Desktop/a.py", line 2, in <module>
a = webdriver.Firefox(firefox_binary='/usr/local/bin/geckodriver')
File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 150, in __init__
keep_alive=True)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 104, in check_response
status = value["status"]
KeyError: 'status'
when webdriver is called without binary from Terminal, the browser opens and i get:
Traceback (most recent call last):
File "/Users/avihaiezaguy/Desktop/a.py", line 2, in <module>
a = webdriver.Firefox()
File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 150, in __init__
keep_alive=True)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 180, in start_session
self.session_id = response['sessionId']
KeyError: 'sessionId'
on the other hand Chrome works fine.
can anyone help solving this issue?
after looking at: https://github.com/mozilla/geckodriver/releases
upgraded selenium from 3.0.2 to 3.3.1 with
pip install -U selenium
now it's working!
Related
I am trying to run selenium using python3.8 and firefox. Tried using the latest two geckodriver version. Getting this error.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/insurance_monitor/env/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 170, in __init__
RemoteWebDriver.__init__(
File "/root/insurance_monitor/env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/root/insurance_monitor/env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/root/insurance_monitor/env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/root/insurance_monitor/env/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1
Seems like the reason is... I was trying to run on Cloud. Had to set it headless
I want to run InstaPy on windows based on this instructions
so I installed it until step 3 and I'm in the advanced setup. because simple set up did'nt work for me.
now i have installed GUI tool from an .exe setup file and running the bot will open a chrome page like this and after a while I get attached error bellow. what should I I do? where did I go wrong?
Im google chrome Version 68.0.3440.75 (Official Build) (64-bit) and currently I use chromedriver.exe version 2.4 and python 3.6.5
first I see this chrome page:
and after that I see this error in GUI
the error is this
Error: ERROR [2018-07-26 11:16:27] [mohammad.f.rasoulnejad] Message: unknown error: unable to discover open pages
(Driver info: chromedriver=2.4.226107,platform=Windows NT 6.3 x86_64)
Traceback (most recent call last):
File "C:\Users\Mohammad\Desktop\InstaPy\instapy\instapy.py", line 295, in set_selenium_local_session
chrome_options=chrome_options)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open pages
(Driver info: chromedriver=2.4.226107,platform=Windows NT 6.3 x86_64)
Traceback (most recent call last):
File "C:\Users\Mohammad\Desktop\InstaPy\instapy\instapy.py", line 295, in set_selenium_local_session
chrome_options=chrome_options)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open pages
(Driver info: chromedriver=2.4.226107,platform=Windows NT 6.3 x86_64)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "quickstart.py", line 3, in <module>
session = InstaPy(username='mohammad.f.rasoulnejad', password='myPassword')
File "C:\Users\Mohammad\Desktop\InstaPy\instapy\instapy.py", line 188, in __init__
self.set_selenium_local_session()
File "C:\Users\Mohammad\Desktop\InstaPy\instapy\instapy.py", line 299, in set_selenium_local_session
Settings.chromedriver_location))
instapy.instapy.InstaPyError: ensure chromedriver is installed at C:\Users\Mohammad\Desktop\InstaPy\assets\chromedriver
InstaPy ended
UPDATE:
I downloaded the 2.40 and placed it in assets folder but its 2.4.226107 in the error message
chromedriver=2.4.226107
DevTools listening on ws://127.0.0.1:12969/devtools/browser/c5a3dd55-34fb-4723-9161-6b8a6e469b29
ERROR [2018-07-26 12:58:34] [mohammad.f.rasoulnejad] Message: unknown error: unable to discover open pages
(Driver info: chromedriver=2.4.226107,platform=Windows NT 6.3 x86_64)
Traceback (most recent call last):
File "C:\Users\Mohammad\Desktop\InstaPy\instapy\instapy.py", line 295, in set_selenium_local_session
chrome_options=chrome_options)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open pages
(Driver info: chromedriver=2.4.226107,platform=Windows NT 6.3 x86_64)
Traceback (most recent call last):
File "C:\Users\Mohammad\Desktop\InstaPy\instapy\instapy.py", line 295, in set_selenium_local_session
chrome_options=chrome_options)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "D:\web\Python 3.6.5\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open pages
(Driver info: chromedriver=2.4.226107,platform=Windows NT 6.3 x86_64)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "quickstart.py", line 3, in <module>
session = InstaPy(username='mohammad.f.rasoulnejad', password='myPassword')
File "C:\Users\Mohammad\Desktop\InstaPy\instapy\instapy.py", line 188, in __init__
self.set_selenium_local_session()
File "C:\Users\Mohammad\Desktop\InstaPy\instapy\instapy.py", line 299, in set_selenium_local_session
Settings.chromedriver_location))
instapy.instapy.InstaPyError: ensure chromedriver is installed at C:\Users\Mohammad\Desktop\InstaPy\assets\chromedriver
This error message...
Message: unknown error: unable to discover open pages
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowsing session through Chrome Browser.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.4
chromedriver=2.4 is pretty old and ancient.
You are using Google Chrome Version 68.0.3440.75 (Official Build) (64-bit)
Release Notes of ChromeDriver v2.40 clearly mentions the following :
Supports Chrome v66-68
So there is a clear mismatch between the ChromeDriver v2.4 and the Chrome Browser v68.0
Solution
As you are using Google Chrome Version 68.0.3440.75 as per the Release Notes you need to use a compatible ChromeDriver binary.
Download the compatible ChromeDriver binary i.e. ChromeDriver v2.40 (2018-06-07) from ChromeDriver - WebDriver for Chrome.
Update
As you mentioned, even after upgrading to chromedriver=2.40 you still se the ChromeDriver version as chromedriver=2.4, you can override the previous version within OS PATH by explicitly mentioning the argument executable_path as follows:
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe')
I'm using Python 2.7 and, since I want to program a simple auto-login bot, I've installed Selenium and Geckodriver. After looking around on the Internet (here too), I put the Geckodriver executable in /usr/local/bin. Now, when I try to do:
from selenium import webdriver
driver = webdriver.Firefox()
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 152, in __init__
keep_alive=True)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 98, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 188, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities
Why is that and how should I fix this problem?
Hi I have tried to run the code which is used to open a browser, enter URL and close the browser(https://splinter.readthedocs.io/en/latest/) using SPLINTER in python. The sample code in the above URL is what I tried.
I got the following errors:
C:\Users\irgfff\Desktop>python browse.py
Traceback (most recent call last):
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-
32\lib\subprocess
.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-
32\lib\subprocess
.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "browse.py", line 4, in <module>
with Browser() as browser:
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\splinter\browser.py", line 63, in Browser
return driver(*args, **kwargs)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\splinter\driver\webdriver\firefox.py", line 48, in __init__
timeout=timeout)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\selenium\webdriver\firefox\webdriver.py", line 142, in __init__
self.service.start()
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver'
executable needs to be in PATH.
Could you let me know what I need to configure to avoid these errors ?
I am using Python 3.6.1
Firefox Version - 52
SPLINTER version 0.7.5
I have solved this problem. You must add PATH the location of geckodriver and webdriver.
You can download geckodriver(https://github.com/mozilla/geckodriver/releases) here.
good luck
The script is:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.python.org")
and this come out:
/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/GeniusV/Documents/pythonProject/untitled/hj.py
Traceback (most recent call last):
File "/Users/GeniusV/Documents/pythonProject/untitled/hj.py", line 5, in <module>
driver = webdriver.Firefox()
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 103, in __init__
self.binary, timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 67, in launch_browser
self._start_from_profile_path(self.profile.path)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 90, in _start_from_profile_path
env=self._firefox_env)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
i really don't understand why,is it my python or selenium's problem?
Sounds like a compatibility issue.
Make sure you are using the latest selenium:
pip install --upgrade selenium
And have the latest Firefox installed.