0
driver.get("MyURL");
System.out.println("URL is opened");
executeAutoItScript(scriptFileLocation);

when i open the URL i get an Authentication Required pop up. To handle that I am using AutoIt script. But the problem is As soon as the first command

(driver.get("MyURL");) 

is executed, Chrome will get open and the Authentication pop up appears. And i have observed that the second line

 System.out.println("URL is opened");     

is not being executed. I debugged it and observed that the control is not given to next line from

driver.get("MyURL"); 

and it hangs there. I changed driver.get("MyURL"); to driver.navigate().to("MyURL"); but there is no luck. Could anyone please help me to resolve this. Attached is the pop up screenshot. enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Pulkit Agrawal
  • 331
  • 2
  • 15
  • I think it's a JavaScript window not window pop up, I am not sure though. – Rajagopalan Jul 26 '18 at 02:36
  • Can you check whether alert exists? If it returns true then it's JavaScript pop up not window pop up, Once we know it's JavaScript pop up we can easily solve this problem. – Rajagopalan Jul 26 '18 at 02:38
  • The downvoter can explain why this question is down voted! I see this question is perfectly valid question. – Rajagopalan Jul 26 '18 at 02:39

4 Answers4

1

As per your code trials and the browser snapshot, it seems that the Browser Client (i.e. the Google Chrome Browser) is not returning back the control to the WebDriver instance and subsequently Selenium Java Client can't achieve the state of 'document.readyState' equal to "complete". Hence neither your next line of code:

System.out.println("URL is opened");

is getting executed, nor the AutoIt Script in next line:

executeAutoItScript(scriptFileLocation);

Solution

It is not clear from your question about the source of this Authentication Popup. Perhaps following the discussion Selenium - Basic Authentication via url you can pass the username and password being embedded within the URL as follows:

driver.get("http://admin:admin123@MyURL");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

From: http://selenium-python.readthedocs.io/navigating.html

WebDriver will wait until the page has fully loaded (that is, the onload event has fired) before returning control to your test or script. It’s worth noting that if your page uses a lot of AJAX on load then WebDriver may not know when it has completely loaded. If you need to ensure such pages are fully loaded then you can use waits.

So, in this case your webpage is not fully loaded since it requires authentication. Here is what you can do

driver.get("MyURL");
executeAutoItScript(scriptFileLocation);
Thread.sleep(2000);// to wait for autoit script, you can also use other wait explicit wait
//Assert statement
System.out.println("URL is opened");
theGuy
  • 683
  • 5
  • 15
  • It is not related to wait issue. I am already using the code in debug mode and driver.getURL() is not giving the control to the next line. – Pulkit Agrawal Jul 26 '18 at 05:18
0

->First define the page load time for the driver.

->By using try-catch time out exception invoke the url.

->After that use robot class key events or key events class to enter the authentication details

Try the below one if any queries do lemme know:

driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

try{
driver.navigate().to("yourURL");
}
catch(TimeoutException te){
System.out.println(te);
System.out.println("Line went to Upto that Link");

after this you could proceed with the authentication pop-up code.

Do lemme know if you have any queries.

Fury
  • 142
  • 1
  • 12
0

This helped me:

    InternetExplorerOptions options = new InternetExplorerOptions();
    options.setCapability("initialBrowserUrl", "about:blank");
    options.setPageLoadStrategy(PageLoadStrategy.NONE);

    WebDriver driver = new InternetExplorerDriver(options);
    driver.manage().deleteAllCookies();
    driver.manage().window().maximize();
    driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

    driver.get(url);

//execute AutoItScript goes here