S
S
Space Around2020-09-13 17:18:12
Node.js
Space Around, 2020-09-13 17:18:12

How to connect through a proxy with authentication to a site using Selenium + Firefox?

How to connect through a proxy with authentication (login and password) to the site using Selenium + Firefox?
As I understand it, Selenium does not support connecting to a proxy with authentication out of the box, but I can still use a proxy server, it just won’t give me access to sites and a window will appear for entering a login and password, but the window does not appear and the specified proxy server not used.
What I tried:
1)

let option = new firefox.Options().headless()
.setPreference("network.proxy.type", 1)
.setPreference("network.proxy.http", ip)
.setPreference("network.proxy.http_port", port)
.windowSize(screen);

let driver = new Builder()
.forBrowser('firefox')
.setFirefoxOptions(option)
.build();

2)
let option = new firefox.Options().headless().addArguments('--proxy-server=http://ip:port')

let driver = new Builder()
.forBrowser('firefox')
.setFirefoxOptions(option)
.build();

3)
let driver = new Builder()
.forBrowser('firefox')
.setFirefoxOptions(option)
.setProxy(proxy.manual({
    http: 'ip:port'
}))
.build();

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question