I am taking Selenium error - python

Using 1 seconds of delay
Traceback (most recent call last):
File "instaBrute.py", line 142, in <module>
main()
File "instaBrute.py", line 136, in main
driver = webdriver.Firefox(profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7f1aaba35110>> ignored
I am using Last Version of Kali Linux , and when I want to use program which using selenium , I take this error . So I try "pip uninstall selenium " - "pip install selenium " again , and nothing changes . Thanks for helps

Choose appropriate version of the driver from this page, download and unarchive it, then place to the directory your script is located at.

Related

selenium script doesn't run in python

Tried executing
from selenium import webdriver
browser=webdriver.Chrome()
browser.get('http://www.google.com')
but doesn't execute and throws error
=RESTART: C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\drive.py =
Traceback (most recent call last):
File "C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1178, 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 "C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\drive.py", line 4, in <module>
browser=webdriver.Chrome()
File "C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
properly installed selenium using pip install
Please Help!!
This isn't working because you haven't provide path of the chrome driver.WebDriver doesn't know where is the chromedriver path.
driver = webdriver.Chrome("path of the chrome driver Chromedriver.exe")
for example:
from selenium import webdriver
driver = webdriver.Chrome("d:/chromedriver/Chromedriver.exe")
driver.get("https://www.google.com")
You can try Firefox for this purpose:
First Download Geckodriver from here: https://github.com/mozilla/geckodriver/releases/tag/v0.24.0
from selenium import webdriver
fox = webdriver.Firefox(executable_path='/path/to/downloaded/gecko/driver')
fox.get("https://www.google.com")
Same could be done with google chrome :
You can download chrome driver from here:
https://sites.google.com/a/chromium.org/chromedriver/home
No need to setup PATH variable.
I have just fixed the issue. You need to download an updated version of Google Chrome. For instance, my old version was 96 but now it is 101. That is it.

How to set up Python 3 Selenium/Geckodriver for Firefox on Windows 10?

Saw a lot of people have had problems like this, but in all my searches I saw a lot of conflicting and confusing information that I didn't understand - this is all a bit out of my newbie depth.
I installed Selenium in PyCharm and was attempting to run this code from the book Automate The Boring Stuff with Python:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://inventwithpython.com')
linkElem = browser.find_element_by_link_text('Read It Online')
type(linkElem)
linkElem.click() # follows the "Read It Online" link
Running it throws the following exceptions:
Traceback (most recent call last):
File "C:\Users\LB\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\LB\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\LB\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 "C:/Users/LB/Desktop/PythonProjects/AutomateTheBoringStuffProjects/generalTestingFile.py", line 2, in <module>
browser = webdriver.Firefox()
File "C:\Users\LB\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 142, in __init__
self.service.start()
File "C:\Users\LB\AppData\Local\Programs\Python\Python36-32\lib\site-packages\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.
I've downloaded the latest geckodriver.exe (specifically the 64bit version since I'm on 64bit OS but I'm running 32bit Firefox if that's okay?), but I'm not sure where to put it.
I've looked up how to change a PATH but I don't know what exactly I'm supposed to change or where it's supposed to point to. (Firefox folders? Python folders?)
Followed someone's advice to put geckodriver.exe in C:\Users\LB\ and edit the System Path to ADD that location to the Variable called Path. And now the code works! (You can apparently put geckodriver.exe anywhere, as long as you point the path to that specific folder.)
Source: https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/
This answer was posted as a comment to the question How to set up Python 3 Selenium/Geckodriver for Firefox on Windows 10? by the OP LBoot.

Selenium Service Object Error when opening Webdriver with Firefox in Python

I'm trying to utilize python selenium with firefox in accordance with the documentation, but I get the below error
See below for my script
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://www.google.com/")
See below for my error
Traceback (most recent call last):
File "/Users/Chris/Desktop/firefox_try.py", line 3, in <module>
driver = webdriver.Firefox()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium-3.0.1-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium-3.0.1-py2.7.egg/selenium/webdriver/common/service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x1006890d0>> ignored
I've tried re-installing selenium's python bindings, which I did by just installing from this link with little luck: https://pypi.python.org/pypi/selenium#downloads
Looks like the 'geckodriver' executable needs to be in your PATH.
Here's a site explaining how to set up the webdriver: https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
The command that they specify to add geckodriver to path is:
export PATH=$PATH:/path/to/geckodriver
I'd suggest you put it in ~/.local/bin

selenium and web2py from killer-web-development.com doesn't work

I am trying to follow the tutorial on http://killer-web-development.com/section/4/3
and I am running into the error message:
======================================================================
ERROR: setUpClass (test_static_pages.TestHomePage)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Applications/web2py.app/Contents/Resources/applications/tukker/functional_tests.py", line 18, in setUpClass
self.browser = webdriver.Firefox()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 51, in __init__
self.binary, timeout),
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 46, in __init__
self.binary.launch_browser(self.profile)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 44, in launch_browser
self._wait_until_connectable()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 86, in _wait_until_connectable
self.profile.path, self._get_firefox_output()))
WebDriverException: Message: 'Can\'t load the profile. Profile Dir: /tmp/tmpXWOMML Firefox output: 1409783847270\taddons.manager\tDEBUG\tLoaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]\n1409783847271\taddons.manager\tDEBUG\tLoaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]\n1409783847272\taddons.xpi\tDEBUG\tstartup\n1409783847273\taddons.xpi\tDEBUG\tSkipping unavailable install location app-system-share\n1409783847283\taddons.xpi\tDEBUG\tcheckForChanges\n1409783847286\taddons.xpi\tDEBUG\tNo changes found\nJavaScript error: chrome://browser/content/urlbarBindings.xml, line 674: aUrl is undefined\n'
What is wrong? I am on MacOsX maverics and have installed selenium using macports if that is of any help.
The reason you have problems is because you have a brand new browser and an old selenium.
You need to do two things:
upgrade selenium package to the latest (currently 2.42.1) version
downgrade Firefox to 28 version

Instance of Firefox WebDriver is not created with selenium python bindings

I installed selenium-python bindings and trying to create an instance of firefox web driver
as below
>>> from selenium import webdriver
>>> driver = webdriver.Firefox()
I dont know whats wrong here and its displaying the following error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 51, in __init__
self.binary, timeout),
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 44, in launch_browser
self._wait_until_connectable()
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 81, in _wait_until_connectable
self._get_firefox_output())
selenium.common.exceptions.WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: cannot open display: :1100\n'
Can any please let me know how to solve this ..............
The error says"cannot open display: :1100". Are you running it on a remote terminal? Make sure you can type "firefox" at the prompt and have the browser open (that is what Webdriver does - opens Firefox on your system and then trying to connect to it). If you are running it on a remote system, do a web search on connecting to X display remotely.

Categories