1

I'm using Selenium to automate some stuff, i need to use proxy but my proxy use Basic access authentication so i need to put user and password, i already using: --proxy-server=http://127.0.0.1:8001 arg to setup proxy server, doing some research i found this arg: --proxy-user-and-password but it seems that is invalid. Is possible to configure this via arg?

2
  • Here are solutions that you could try and let me know if one works or is at least relevant for you. post1, post2, post3. – harrymc May 4 '20 at 20:20
  • Hi @harrymc, i saw yours links, but don't work for me because i trying to use chrome in headless mode. – Gaspar May 6 '20 at 15:15
1
  • Edit

enter image description here

search_form = browser.find_element_by_id('search_form_input_homepage')
search_form.send_keys('username')
search_form.send_keys('password')
search_form.submit() 

See more here

Maybe using inputs with Sendkeys in ?

enter image description here

$wshell = New-Object -ComObject wscript.shell
$obj = New-Object -com Wscript.Shell
$wshell.Run('Chrome'),9
Start-Sleep -m 700
[System.Windows.Forms.SendKeys]::SendWait("{TAB}") 
Start-Sleep -m 250
[System.Windows.Forms.SendKeys]::SendWait("username") 
Start-Sleep -m 250
[System.Windows.Forms.SendKeys]::SendWait("pasword")
Start-Sleep -m 250
[System.Windows.Forms.SendKeys]::SendWait("~")`

You may need to adjust the timeout and the keys needed to navigate your interface

[System.Windows.Forms.SendKeys]::SendWait("{TAB}{TAB}") interface/selenium 
Start-Sleep -m `550
2
  • I'm using Selenium with Pythoh in a *nix environment in headless mode. – Gaspar May 6 '20 at 15:17
  • Why not give a try in linux/python with pyautogui – It Wasn't Me May 6 '20 at 15:46
1

I believe it's not currently possible: https://chromium.googlesource.com/chromium/src/+/HEAD/net/docs/proxy.md#proxy-credentials-in-manual-proxy-settings

Most platforms' manual proxy settings allow specifying a cleartext username/password for proxy sign in. Chrome does not implement this, and will not use any credentials embedded in the proxy settings.

Proxy authentication will instead go through the ordinary flow to find credentials.

Workarounds that come to mind:

  • Manually create a profile with the right setup, copy the folder, and point Chrome to it via the --user-data-dir option.
  • There are extensions that do the proxy login automatically as soon as the browser is opened.
  • Spawn stunnel locally and put it "in the middle" (Chrome --no pwd--> stunnel --user:pwd--> real proxy). See How to chain proxies with Firefox or Chrome?

If you're curious and want to try it out (who knows, maybe Chrome will support it one day!) the URL would have been http://username:password@127.0.0.1:8001

2
  • The user:password@ip don't work :( – Gaspar May 6 '20 at 15:16
  • Try setting up a profile and copying it, or spawning stunnel (see edit) – Jacopo May 6 '20 at 16:54
0

When you are lacking a means of supplying the proxy with user-name and password, you could perhaps solve this by using a two-step proxy :

  1. A local proxy server on your computer without user-name and password
  2. The local proxy should connect to the real external proxy using the user-name and password.

A possible solution is installing node.js together with proxy-password-automator, but this depends on your environment.

If you don't have a suitable proxy product, or if the above does not relate to your environment, I would need more detail about the environment to suggest a suitable one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.