3

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.

  • 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: 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. – keasav rao 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 ? – keasav rao 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
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)

  • thanks dan, My Test cases runs against chrome browser. Is their any solution for the same. – keasav rao Sep 14 '17 at 6: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: sqa.stackexchange.com/questions/12403/… – Dan Sep 14 '17 at 6:43
  • Hi Keasav, How did you go getting it working? if its working please close the question by marking this question as answered. – Dan Sep 20 '17 at 2:04
  • Hi Dan, Currently it worked in chrome entering usernamen and password in URL [ browser.driver.get("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.) – keasav rao Sep 20 '17 at 8: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. – Dan Sep 21 '17 at 0: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.

  • Thanks demouser123. sounds interesting reading, particular the second with different credentials. login on chrome now on my bucket list. – Dan Sep 21 '17 at 8: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. – keasav rao Sep 22 '17 at 9: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);
                      }

                    });
New contributor
Vijay N is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.