import os
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
options.add_argument('-profile')
options.add_argument('/home/qwentor/share/test/profiles/profile1')
gecko = os.path.normpath(os.path.join(os.path.dirname(__file__), 'firefox', 'geckodriver'))
binary = FirefoxBinary(r'/home/qwentor/share/test/firefox/firefox-bin')
driver = webdriver.Firefox(firefox_binary=binary, executable_path=gecko, options=options)
driver.get("https://ifconfig.co")
driver.get_screenshot_as_file('/home/qwentor/share/test/screen5.png')
driver.close()
Traceback (most recent call last):
File "testbrowser2.py", line 34, in <module>
driver = webdriver.Firefox(firefox_binary=binary, executable_path=gecko, options=options)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: connection refused