I'm using selenium with Python3. Here's my code:
import socks
import socket
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
socks.set_default_proxy(socks.SOCKS5, "localhost", 9150)
socket.socket = socks.socksocket
opts = Options()
opts.set_headless()
assert opts.headless
browser = Firefox(options=opts)
browser.get('http://checkip.dyndns.org')
browser.save_screenshot('ip.png')
I receive
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service geckodriver
on the line
browser = Firefox(options=opts)
Problem in the following lines:
socks.set_default_proxy(socks.SOCKS5, "localhost", 9150)
socket.socket = socks.socksocket
If I remove them, code work normally. Why does it happens? How should I fix that?