0

I am struggling a bit while automating an authentication pop up in the chrome browser. I am using this test site named "http://the-internet.herokuapp.com/basic_auth"

Here is my code.

public class Authen {

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub

         System.setProperty("webdriver.chrome.driver", "C:\\Users\\Sumedha\\OneDrive\\Documents\\Selenium\\Drivers\\chromedriver_win32\\chromedriver.exe");
          WebDriver driver = new ChromeDriver();
driver.get("http://the-internet.herokuapp.com/basic_auth");
     Runtime.getRuntime().exec("C:\\Users\\Sumedha\\OneDrive\\Documents\\Selenium\\AutoIT\\handleauthentication.exe");   
    }
}

This is how my autoIT script looks.

WinWaitActive("Sign in")
Send("admin")
Send("{TAB}")
Send("admin")
Send("{ENTER}")

Now when I run this, credentials are not entered in the popup and script does not run at all.

Please help !

Thanks in Advance.

user3624146
  • 369
  • 1
  • 5
  • 16
  • Possible duplicate of [How to handle authentication popup with Selenium WebDriver using Java](https://stackoverflow.com/questions/24304752/how-to-handle-authentication-popup-with-selenium-webdriver-using-java) – GPT14 May 11 '18 at 06:18
  • 1
    Use driver.get("http://username:password@http://the-internet.herokuapp.com/basic_auth"); – cruisepandey May 11 '18 at 06:32
  • 1
    Possible duplicate of [Selenium - Basic Authentication via url](https://stackoverflow.com/questions/45345882/selenium-basic-authentication-via-url) – undetected Selenium May 11 '18 at 09:18
  • 1
    @DebanjanB. Link was really helpful. Thanks – user3624146 May 11 '18 at 13:53

1 Answers1

2

as cruisepandey writes, only Basic Authentication credentials can be added direct into the url

where as some credential alerts are not browser's component, but OS's.

those pop-ups are not accessible via selenium, a malware could penetrate if it would be possible.

BasicAuthentication put your credentials direct to URL: https://{username}:{password}@host.com

OAuth with Manually entered Credentials need a UIAutoamtion based tool, some examples: AutoIT or Python uiautomation.

dank8
  • 361
  • 4
  • 20
pburgr
  • 1,722
  • 1
  • 11
  • 26