4

Use case:

When URL loads, it request for Windows authentication (Enter Username and Password). How it goes is:

  1. loads the url

  2. on clicking Post button in the page. Windows Authentication pops up appears asking for username and password.

    enter image description here

Tried:

Installed AutoIT and written script and generated a exe file.

Question

  1. How to call this in protractor javascript? Something like runtime.getruntime.exe("path/.exe")

  2. Or is their any another way to achieve it.

  3. Highly appreciate, if you explain at code level as well as I am new to javascript.

alecxe
  • 11,425
  • 10
  • 49
  • 107
Bustaq
  • 403
  • 4
  • 12
  • 20
  • Are you sure you have to do it with AutoIT? You can specify the username and a password inside the URL string, try it out: https://stackoverflow.com/a/24305626/771848. – alecxe Sep 13 '17 at 11:05
  • Usecase : 1)loads the url 2)on clicking Post button in the page. Windows Authentication pops up appears asking for username and password. – Bustaq Sep 13 '17 at 11:15
  • @alecxe ,tested again. it did worked after entering username and password in url. Next is, How to verify the json response ? – Bustaq Sep 13 '17 at 12:33
  • 1
    @alecxe isn't this not recommended? I think Chrome starting version 59, has blocked passing URL with username and password. – demouser123 Sep 13 '17 at 18:03
  • @demouser123 yeah, I think both Chrome and IE dropped support for that, I am a bit out of date on that. But, thanks, good to know. – alecxe Sep 13 '17 at 18:07
  • thanks guys, i am testing against Chrome Browser. Is their any alternative solution/Approach. that get work with chrome. – Bustaq Sep 14 '17 at 06:04

3 Answers3

2

A workaround (had similar issues with selenium) was to use Firefox, and create a browser profile that includes a password and let the browser populate the login screen.

Firefox (I have successfully implemented these steps)

Chrome (Suggestions, i have not tried configuring Chrome profiles before)

dank8
  • 251
  • 1
  • 6
  • thanks dan, My Test cases runs against chrome browser. Is their any solution for the same. – Bustaq Sep 14 '17 at 06:06
  • Chrome also has similar feature Settings > Manage Passwords. might just have to play with the feature to see if chrome will autologin or if you still need to click the ok button. (Here is someone-elses answer on another post: https://sqa.stackexchange.com/questions/12403/selenium-code-for-login-popup-window-page#answer-20409 – dank8 Sep 14 '17 at 06:43
  • Hi Keasav, How did you go getting it working? if its working please close the question by marking this question as answered. – dank8 Sep 20 '17 at 02:04
  • 1
    Hi Dan, Currently it worked in chrome entering usernamen and password in URL [ browser.driver.get("https://username:Pass@genqa/site/showGeoLocation/");]. i have latest chrome. And i am looking for ur steps. creating profile that includes password. Do u have any sample code how to achieve this (create a browser profile that includes username and password.) – Bustaq Sep 20 '17 at 08:00
  • Hi Keasav, I have configured Firefox (see links). But have not configured Selenium to use a specific Chrome profile before. hence i have added some links that will get you started. – dank8 Sep 21 '17 at 00:43
1

Based on these two questions- How to handle authentication in Chrome 59 and duplicate question, I think hitting a previous page with the authentication credentials,before the actual authentication page, makes Chrome remember the credentials and then you can use it afterwards.

I haven't implemented this and so I'm not hundred percent sure of this, but you can give it a try.

Also, when you say that you have latest Chrome and you're able to pass username:Pass@genqa/site/showGeoLocation‌​/");], I would think that you should report this to Google, if you're Chrome is above 59, since as per this post, support for this has been dropped entirely.

demouser123
  • 3,532
  • 5
  • 28
  • 40
  • Thanks demouser123. sounds interesting reading, particular the second with different credentials. login on chrome now on my bucket list. – dank8 Sep 21 '17 at 08:15
  • hi @demouser123, i reported to google. they justified saying the below. "The changes we made somewhat recently blocked embedded credentials in subresource requests only, not in top-level navigations." So passing username and password in url is valid. – Bustaq Sep 22 '17 at 09:14
0

what's the problem with the code ?

                  handlePromise = browser.driver.getAllWindowHandles();
                  var promise1 = new Promise(function(resolve,handles) {
                        try {

                        var count=handles.length;
                        console.log("Count F: " +count) ;
                      // var newWindow = handles[count-1];
                        var newWindow = handles[count];
                        browser.driver.switchTo().window(newWindow);
                        browser.sleep(9000);
                        browser.driver.getWindowHandle();
                        browser.driver.executeScript('window.focus();');
                        console.log("Count S: " +count) ;
                        resolve(true);

                        } catch (error) {

                          console.log(error);
                        }


                    });


                    promise1.then(function(value) {
                      try {

                        console.log("promise value from p1" + value);
                        console.log("operation Function");
                      //  browser.actions().click();
                        browser.actions().sendKeys('user01@group.org').perform();
                        browser.sleep(9000);

                      } catch (error) {

                        console.log(error);
                      }

                    });