Selenium - Https issue with PhantomJS and Proxy Auth with Firefox

OK, so my goal is to connect to the https site through a proxy server that requires authentication without any human interaction.

Solution # 1: Firefox

fp = webdriver.FirefoxProfile()
fp.set_preference("network.proxy.type", 1)
fp.set_preference("network.proxy.http", "IP")
fp.set_preference("network.proxy.http_port", PORT)
driver = webdriver.Firefox(firefox_profile=fp)
driver.get("http://www.google.com")

problem: as soon as the browser opens, it will open an auth popup for username and password.

alert = driver.switch_to_alert()
alert.send_keys('balbla')

doesn't work, no answer at all. also unlucky with changing proxy to

http://username:password@ip

solution # 2: PhantomJs

with phantomjs I managed to do authentication in code:

service_args = [
    '--proxy=https://IP:PORT',
    '--proxy-type=http',
    '--proxy-auth=USERNAME:PASSWORD',
    ]
br = webdriver.PhantomJS(PATH,service_args=service_args)
br.get('https://www.google.com/')

problem: I cannot go to any https website , for example, I try to enter https : //www.gmail.com, I get a blank page. the proxy works with https for sure (double checked manually).

adding

'--ssl-protocol=any'

does not work.

python Linux env. , .

.

+4
1

, :) - https - https i.e.:

service_args = [
    '--proxy=IP:PORT',
    '--proxy-type=https',
    '--proxy-auth=USERNAME:PASSWORD',
    ]
0

Source: https://habr.com/ru/post/1618927/


All Articles