$uname -a
Linux archdeekus 4.11.3-1-ARCH #1 SMP PREEMPT Sun May 28 10:40:17 CEST 2017 x86_64 GNU/Linux
$pip3 show selenium
Name: selenium
Version: 3.4.3
Summary: Python bindings for Selenium
Home-page: https://github.com/SeleniumHQ/selenium/
Author: UNKNOWN
Author-email: UNKNOWN
License: Apache 2.0
Location: /usr/lib/python3.6/site-packages
Requires:
$firefox -v
Mozilla Firefox 55.0.3
55.0.3(64-bit)
```Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python3.6/multiprocessing/process.py", line 249, in _bootstrap
self.run()
File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
self._target(self._args, *self._kwargs)
File "ProxLoadMe.py", line 186, in retrieve_source
switcher = parse_file(hoster, name, currthreads, iterator)
File "ProxLoadMe.py", line 197, in parse_file
driver = init_webdriver()
File "ProxLoadMe.py", line 51, in init_webdriver
return webdriver.Firefox(firefox_options=options, log_path="geckodriver.log")
File "/usr/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 118, in __init__
if firefox_options.binary is not None:
AttributeError: 'Options' object has no attribute 'binary'
## Steps to reproduce -
def init_webdriver():
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "/usr/bin/firefox"
options.add_argument("-headless")
return webdriver.Firefox(firefox_options=options, log_path="geckodriver.log")
driver = init_webdriver()
driver.close()
Using options.binary = "/usr/bin/firefox" following error appears:
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python3.6/multiprocessing/process.py", line 249, in _bootstrap
self.run()
File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
self._target(self._args, *self._kwargs)
File "ProxLoadMe.py", line 186, in retrieve_source
switcher = parse_file(hoster, name, currthreads, iterator)
File "ProxLoadMe.py", line 197, in parse_file
driver = init_webdriver()
File "ProxLoadMe.py", line 51, in init_webdriver
return webdriver.Firefox(firefox_options=options, log_path="geckodriver.log")
File "/usr/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 120, in __init__
if firefox_options.profile is not None:
AttributeError: 'Options' object has no attribute 'profile'
/usr/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py references to /usr/lib/python3.6/site-packages/selenium/webdriver/firefox/options.py, which contains:
def __init__(self):
self._binary = None
self._preferences = {}
self._profile = None
self._proxy = None
self._arguments = []
self.log = Log()
```
Calling webdriver.Firefox(log_path="geckodriver.log") simply opens Firefox.
Typo killed me here, sorry.
how you solve this? noob here :S
Why is this closed?
If you'd read carefully:
from selenium.webdriver.chrome.options import Options
```python
options = Options()
```python
options.binary_location = "/usr/bin/firefox"
options.add_argument("-headless")
```python
return webdriver.Firefox(firefox_options=options, log_path="geckodriver.log")
This Issue was resolved by *reading* (it was 2 a.m.)
#### Here is a quick snip that will do the job for you:
```python
from shutil import which
from selenium import webdriver
```python
FIREFOXPATH = which("firefox")
CHROMEPATH = which("chrome") or which("chromium")
```python
def init_webdriver():
"""Simple Function to initialize and configure Webdriver"""
if FIREFOXPATH != None:
print(FIREFOXPATH)#cm
from selenium.webdriver.firefox.options import Options
options = Options()
options.binary = FIREFOXPATH
options.add_argument("-headless")
return webdriver.Firefox(firefox_options=options, log_path="geckodriver.log")
elif CHROMEPATH != None:
print(CHROMEPATH)#cm
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = CHROMEPATH
options.add_argument("--headless")
return webdriver.Chrome(chrome_options=options, service_args=['--verbose'], service_log_path="chromedriver.log")
Usage:
driver = init_webdriver()
...
Don't forget to mention.
Most helpful comment
If you'd read carefully:
```python
options = Options()
```python
return webdriver.Firefox(firefox_options=options, log_path="geckodriver.log")
```python
FIREFOXPATH = which("firefox")
CHROMEPATH = which("chrome") or which("chromium")
Usage:
Note, the Browser(s) will be started headless, unless you remove the corresponding line
Don't forget to mention.