0

Please note that my question is not a duplicate of Python Selenium Alert -- Prompt username and password is not working. In my case it's not working for Chrome not Firefox, for Firefox it is working. Also I've tried the solution provided in the bug and it didn't work for Chrome.

Here is the code sample

wait(driver, 5).until(EC.alert_is_present())
alert = driver.switch_to_alert()
alert.send_keys("username" + Keys.TAB + "password")
alert.accept()

Expected behavior is - keys are correctly send to popup.

I'm getting timeout exception on line 1 - selenium.common.exceptions.TimeoutException: Message:

when actually the alert is present. authentication popup

When removing line 1, I'm getting exception on line 2 selenium.common.exceptions.NoAlertPresentException: Message: no alert open

Any ideas on this? How can I pass the credentials with chromedriver? Also I'll need to be able to perform this in headless mode on linux commandline server.

I've found workaround:

def __getCapabilitiesForChrome(ip, port, user, password):
    proxy = {'address': user + ":"+password+"@"+ip + ':' + str(port),
             'username': user,
             'password': password}

    capabilities = dict(DesiredCapabilities.CHROME)
    capabilities['proxy'] = {'proxyType': 'manual',
                             'httpProxy': proxy['address'],
                             'ftpProxy': proxy['address'],
                             'sslProxy': proxy['address'],
                             'noProxy': '',
                             'class': "org.openqa.selenium.Proxy",
                             'autodetect': False}

    return capabilities
capabilities = __getCapabilitiesForChrome(ip, port, username, password)
driver = webdriver.Chrome(executable_path='chromedriver.exe', desired_capabilities=capabilities)
driver.get('https://www.foo.bar/')

But actual sending keys is not implemented yet https://github.com/w3c/webdriver/issues/385.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • "*This works as expected with firefox*" you might want to explain **what** is expected *before* even showing the code sample – Rafalon Nov 29 '17 at 10:58
  • for headless mode you can use virtual frame buffer X11 server: http://www.x.org/archive/current/doc/man/man1/Xvfb.1.xhtml It even allows to take screenshots. – Würgspaß Nov 29 '17 at 11:10
  • I've mentioned about headless mode because I've found out workaround using extension ProxyAutoAuth_2_0.crx, but in headless mode chrome doesn't provide support for extensions. – Lilit Hakobyan Nov 29 '17 at 12:11
  • This is not a duplicate, how can I reopen?? – Lilit Hakobyan Nov 29 '17 at 20:19

0 Answers0