-1

i've searched through the sites. and all posts seems to be indicating different methods which may or may not work because i couldnt even get to it because code hang at 'getDriver' or 'navigate' to url. and it doesnt continue to next,

where are all methods supposed to handle the pop up. i learned that both GetDriver and Navigate expects the page fully loaded. i guess this is reason why my code will stuck at beginning, because authentication pop up is as very first thing before page is loaded fully.

in this case what should i do? i tried the method below
http://username:password@example.com to log in, but maybe because my username has "domain/username" in it , its not working, i also added the "/" at the end. didnt work. pop up dialog

        boolean presentFlag = false; 
      try {    getDriver().navigate().to("http://domain%5username:password@blahblah/blah-intranet/");
    // code always at above  because the authentication pop up not letting page load fully 

   anycode().here.doesnt matter cause it doesn't get to it.

g);
  • Are you using proxy? – Tarun Lalwani Aug 10 '17 at 18:01
  • sorry im not really knowledge for it, what is it. – MemphisTony V Montana Aug 10 '17 at 18:05
  • When you open your website manually it requires username and password? – Tarun Lalwani Aug 10 '17 at 18:06
  • Have you checked the answers [here](https://stackoverflow.com/questions/24304752/how-to-handle-authentication-popup-with-selenium-webdriver-using-java)? Do any of those solve your problem? – mrfreester Aug 10 '17 at 18:06
  • 1
    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) – JeffC Aug 10 '17 at 18:22
  • Show us your code for better help on the situation. Also as mrfreester linked, have you tried using a profile? – IamBatman Aug 10 '17 at 18:23
  • @TarunLalwani: yes, it does from the popup dialog "Authentication Required" – MemphisTony V Montana Aug 10 '17 at 18:24
  • @IamBatman: anycode after getDriver doesnt seems matter because it doesnt get to that step at all. – MemphisTony V Montana Aug 10 '17 at 18:24
  • Screenshot the "Authentication Required". Is it your standard "browser popup" or a programmed popup from the site? All these may be valuable questions to answer your question correctly. – IamBatman Aug 10 '17 at 18:25
  • @IamBatman Added the pic at end of original artical – MemphisTony V Montana Aug 10 '17 at 18:36
  • @JeffC in that post they have method using AutoIt, Setting Firefox profile, and proxy and using the url to pass uid pwd to it. none of it worked except i havent tried firefox, because i may have to use chrome instead or IE. i was wondering if there's a way to by pass page loading, to handle pop up first – MemphisTony V Montana Aug 10 '17 at 18:37
  • @IamBatman as you can see, page shows loading for over an hour now. and my code is simply not getting to next step other than getDriver().navigate().to(homeURL); – MemphisTony V Montana Aug 10 '17 at 18:42
  • post the homeURL please. Are you immediately trying the user:pass@example or clicking something that brings that up? – IamBatman Aug 10 '17 at 18:49
  • @IamBatman url is internel ,, however, i just encode the 'domain/username' like this 'http://domain%userID:password@blahblah-intranet/' and diffrences now is . when i click in my eclips it brings the page, but when i run the code it still stuck at getDriver().naviagte(url above) , page loads forever, but if i click cancel it bring the page – MemphisTony V Montana Aug 10 '17 at 19:11
  • Why are you putting a "Domain" before the userId and password? Have you tried it without the domain? Have you also tried using "https://" instead of just "http://"?? – IamBatman Aug 10 '17 at 22:43
  • Oh also you said you have to use "Chrome" and "IE". Are you using IE? IE isn't compatible with the "URL" method you are using. Chrome had it removed and added it back, but you can also set profiles for all browsers, not just "Firefox". – IamBatman Aug 10 '17 at 22:47
  • "domain/user" is like this "yahoo/user" "NASA/johnSmith" because user name is like this, – MemphisTony V Montana Aug 11 '17 at 02:06
  • @IamBatman i have been able to bypass the dialog now with that, and i have to cancel the dialog. and continue. however it pops up again with every request i send. that other post thier linking to doesnt have answer for preventing it permanently. i set the profile i used the Autoit, and authenticate using , none worked. i will figure it out – MemphisTony V Montana Aug 11 '17 at 02:08
  • Possible duplicate of [Selenium - Other way to basic authenticate than via url](https://stackoverflow.com/questions/45345882/selenium-other-way-to-basic-authenticate-than-via-url) – undetected Selenium Aug 11 '17 at 05:07

1 Answers1

0

Ok, finally this one resolved for my issue. for those of you who can't use any of the answer that's not specific to this on other posts, here's probably your answer.

for it to do anysteps and not to hang on the browser load. set the browser timer to 0 and use try catch like this.

  try { 

      getDriver().manage().timeouts().pageLoadTimeout(0, TimeUnit.MILLISECONDS);// set it back later if you running whole suite.
      getDriver().navigate().to("http://blahblah/blah-intranet/");
            }catch (TimeoutException ignored) {
            // add solution here to handle pop up
         } 

Solution 1 :

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

// this don't work for me saying the authenticateUsing is @Beta, not working currently

Solution 2:

getDriver().navigate().to("http://Username:password@blahblah/blah-intranet/");  
        alert.dismiss(); 
//if you have Username with domain/username, besure to encode slash to '%5C'
// this worked for me, but the when you're in the page, it still kicks up the pop up again with new request.

Solution 3

Working solution for me! (using AutoIt)

String jacobDllVersionToUse =   "jacob-1.18-x64.dll"; 
                File file = new File("lib", jacobDllVersionToUse);
                System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath()); 
                AutoItX x = new AutoItX();   
// Up untill here , you can get from anywhere on how to set up and get your window activate and so on. please see code below 

             x.winWaitActive("Your authentication Window title");
//very important not x.winActive, above will wait for the page is present at front. this will prevent autoIT to write is all over the place.
              x.send("domain\\seasmeDoor"); //very important, if you have domain slash make sure \\ to encode.
              x.send("{TAB}",false);\\set it false so it will take it as key
              x.send("Password");  
              x.send("{Enter}",false);
IamBatman
  • 975
  • 12
  • 18