“No Alert Open” when trying to put login credentials before the website is opened completely

后端 未结 1 1310
长发绾君心
长发绾君心 2021-01-26 08:30

I am trying to access a website, However to access the website first I need to enter username and password, After that full website will get open. When I try to send username an

1条回答
  •  甜味超标
    2021-01-26 09:13

    driver.get("http://UserName:Password@Example.com"); should do the trick if the site uses basic authentication.

    Special note: if you have @ in your password, don't forget to replace that bad boy by a %40

    In case your authentication server requires username with domain like "domainuser" you need to add double slash / to the url: //localdomain\user:password@example.com

    EDIT:

    Chrome 59 has removed support for https://user:password@example.com URLs.

    You can use the following method to handle it in IE as of selenium 3.4

    WebDriverWait wait = new WebDriverWait(driver, 10);      
    Alert alert = wait.until(ExpectedConditions.alertIsPresent());     
    alert.authenticateUsing(new UserAndPassword(username, password));
    

    There is way of handling this using Chrome extension. More explanation can be found here

    OR

    Downgrade your chrome version to <59

    0 讨论(0)
提交回复
热议问题