Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does selenium python bindings require firefox

Hi I just downloaded and installed selenium but, I can't figure out how to get it working I am using the following example as a test....

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()         #this is where I hit the error
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.send_keys("selenium")
elem.send_keys(Keys.RETURN)
assert "Google" in driver.title
driver.close()

I do not have firefox installed on my computer is this why it is giving me an error? this is the error output I get when I try and run it

Traceback (most recent call last):
  File "C:/Python27/test/helloworld.py", line 4, in <module>
    driver = webdriver.Firefox()
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\firefox\webdriver.py", line 60, in __init__
    self.binary, timeout),
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\firefox\extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\firefox\firefox_binary.py", line 60, in launch_browser
    self._start_from_profile_path(self.profile.path)
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\firefox\firefox_binary.py", line 83, in _start_from_profile_path
    env=self._firefox_env).communicate()
  File "C:\Python27\lib\subprocess.py", line 679, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 893, in _execute_child
    startupinfo)
WindowsError: [Error 87] The parameter is incorrect
like image 236
ZJS Avatar asked Nov 20 '25 16:11

ZJS


1 Answers

Following line starts Firefox browser so yes, it requires installed Firefox.

driver = webdriver.Firefox()  

If you don't have Firefox installed you can use different browser instead:

webdriver.Opera
webdriver.Ie
webdriver.Chrome
...

See

help(webdriver)
like image 84
zero323 Avatar answered Nov 22 '25 07:11

zero323



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!