Use case:
When URL loads, it request for Windows authentication (Enter Username and Password). How it goes is:
loads the url
on clicking Post button in the page. Windows Authentication pops up appears asking for username and password.
Tried:
Installed AutoIT and written script and generated a exe file.
Question
How to call this in protractor javascript? Something like
runtime.getruntime.exe("path/.exe")
Or is their any another way to achieve it.
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– alecxe2017年09月13日 11:05:59 +00:00Commented Sep 13, 2017 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– Bustaq2017年09月13日 11:15:30 +00:00Commented Sep 13, 2017 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– Bustaq2017年09月13日 12:33:09 +00:00Commented Sep 13, 2017 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– demouser1232017年09月13日 18:03:58 +00:00Commented Sep 13, 2017 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– alecxe2017年09月13日 18:07:39 +00:00Commented Sep 13, 2017 at 18:07
3 Answers 3
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)
- Chrome Profile
- Unsure how to configure selenium with Chrome profile
-
thanks dan, My Test cases runs against chrome browser. Is their any solution for the same.Bustaq– Bustaq2017年09月14日 06:06:16 +00:00Commented Sep 14, 2017 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/…dank8– dank82017年09月14日 06:43:01 +00:00Commented Sep 14, 2017 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.dank8– dank82017年09月20日 02:04:35 +00:00Commented Sep 20, 2017 at 2:04
-
1Hi 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.)Bustaq– Bustaq2017年09月20日 08:00:33 +00:00Commented Sep 20, 2017 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.dank8– dank82017年09月21日 00:43:13 +00:00Commented Sep 21, 2017 at 0:43
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.dank8– dank82017年09月21日 08:15:51 +00:00Commented Sep 21, 2017 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.Bustaq– Bustaq2017年09月22日 09:14:36 +00:00Commented Sep 22, 2017 at 9:14
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('[email protected]').perform();
browser.sleep(9000);
} catch (error) {
console.log(error);
}
});
Explore related questions
See similar questions with these tags.