Login to Chrome Authentication window using AutoIT - windows-authentication

I tried login to firefox authentication window by following code :
WinWaitActive("Authentication Required","","120")
If WinExists("Authentication Required") Then
Send("username{TAB}")
Send("password{Enter}")
EndIf
But the same dint worked for chrome even though it has the same title as firefox.
Any idea?

#Milos #Samoth thanks for spending to solve my query.
Using Autoit windows info tool, i could not identify the windows tile in chrome thats not a case in FF or IE. Instead of that "Autentication Required" identified as visible text.
So modifying the code to
WinWaitActive("","Authentication Required","120")
If WinExists("","Authentication Required") Then
Send("username{TAB}")
Send("password{Enter}")
EndIf
did the trick for Chrome browser.

If somebody is interested in Selenium for Chrome using Visual Studio and NUnit Framework, you can follow these steps:
Install AutoItX.Dotnet NuGet package for your testing project
Write the following code:
IWebDriver _driver = new ChromeDriver();
_driver.Navigate().GoToUrl(#"your_url");
AutoItX.WinActivate("", "Authentication required");
AutoItX.Send(#"domain_user_name{TAB}password{ENTER}");
and you are logged in your web application.

A lot of credit for this goes to #CristiG for this.
You will need the AutoItX.Dotnet NuGet package
Use this code to login, just ignore the commented out lines unless you want to see if you can get it to work without the Sleep() for robustness.
new Thread(() =>
{
Thread.Sleep(500);
// AutoItX.WinWait("", "Authentication required");//fails
AutoItX.WinActivate("", "Authentication required");
// AutoItX.WinWaitActive("", "Authentication required");//fails
AutoItX.Send(#"username{TAB}pass{ENTER}");
}).Start();
driver.Url = "http://yourpage.com";
Cristi's method didn't work for me, because the call to GoToUrl() blocks when the login dialog box pops up.
But that can be fixed simply by starting a thread to do the login before calling GoToUrl().
It would seem you could use either WinWait() or WinWaitActive() to eliminate the need for the Thread.Sleep(), but I couldn't get either to work, so I was left with the ugly Thread.Sleep(), but this approach
works for me.

Related

E2E test Protractor issue: redirect to another page in the same window

The website I need to test requires login. However, you have to stay in the same window to keep your login information, which means if you close the window of this page, you need to login again. This gives me the problem: when I am using protractor to test the websites, it seems like each time I use browser.get(url). It will turn off the browser and open another one for the test, then I lost my login information. So I can't test the pages I want to test. Can anybody give me some suggestions, I have not figured it out for one days. Crazy!
describe('Sample List page test', function(){
beforeEach(function(){
browser.driver.get('http://localhost:8600/#/login');
browser.driver.sleep(2000);
browser.driver.findElement(by.id('google-login')).click();
});
it('should list all the items in samples',function(){
browser.get("#/osctr/sample");
expect(browser.getTitle()).toBe("Sample");
}
});
});
In the above codes, I can't get information in the sample page because I used brower.get(url), it will open a new page which I will lose my login information.
When you do browser.driver.get(), it would open a new windown. That's how selenium-webdriver works. There was an issue opened longtime back to attach webdriver instance to an existing browser window which is now marked as NotFeasible.
If you want to keep the browser session intact, you can do browser.driver.get() in before() method instead of beforeEach() and have multiple tests that work on the same browser instance and quit the browser in after method.

Suddenly Facebook API stopped working on Windows Phone

My code hasn't changed, it was working yesterday or so.
I can oauth, get the token but then doing the following:
WebClient wc = new WebClient();
wc.DownloadStringCompleted += result;
wc.DownloadStringAsync(new Uri("https://graph.facebook.com/me&access_token=xxxTOKENxxx", UriKind.Absolute));
Returns a NotFound WebClient exception: "The remote server returned an error: NotFound."
Strange thing is that when pasting that same url on Chrome or IE it does work(PC).
Tried on Emulator and on 2 different real WP devices, even pasting the same url on the WP browser.
Feels like facebook is rejecting Windows Phone for some reason?
Anyone has an idea of what might be happening?
look like there is a bug on Facebook being tracked
click here if you want to follow
https://developers.facebook.com/bugs/367369176650486?browse=search_4fd82eadc62186861827790
after reading the link someone says graph.beta.facebook.com does work instead of graph.facebook.com
I can confirm its not you. WP7 sample from the SDK from GitHub is failing. ASP.NET sample is now returning an "Error occured in . Please try again later." error. As you noted, copying and pasting the URL into IE resolves and returned the expected JSON. Clearly something has changed.

How to redirect to an external url with Selenium, and come back?

I am working in perl with Selenium RC, server version 2.19.0-b09 and I cannot figure out whether it is even possible to redirect to an external URL and come back to my application. I am trying to test Facebook OAuth in my application, which means I have to go to Facebook and come back to my app.
use Test::WWW::Selenium::Catalyst 'MyApp', -selenium_args => 'injectProxyMode -trustAllSSLCertificates -debug -log /home/me/browserlog.txt -firefoxProfileTemplate /home/me/.mozilla/firefox/SeleniumUser.default/';
my $selenium = Test::WWW::Selenium::Catalyst->start({
browser => '*chrome',
});
The reason I think this is possible at all is because a custom Firefox profile and the -injectProxyMode, *chrome browser and -trustAllSSLCertificates options enable me to post to and see all the redirects in my debug log, but my Remote Control window always disappears after the redirects. I can see the PROXY URL to which Facebook is trying to send me back, e.g., a URL on my own base domain. But it looks like there is no window for it to return to. In multiWindow mode I am left with my application in a Firefox window. In singleWindow mode my tests just end and all the windows close.
I have tried both -singleWindow and -multiWindow mode. I have gotten the list of windows after I make my post to https://www.facebook.com:443/login.php... and before all the redirects. I see a single window that is never available to select_window, and it always disappears on the second iteration if I run get_all_window_names in in a while loop: a window with a name like "_e_0RWG".
So, how could I conceivably do what I am trying to accomplish with Selenium? It seems so near and yet so far.

Facebook Login throws "Permission denied"

I am adding Facebook login to my existing asp.net application. I have added a Facebook login button to my login screen. Now, I click Facebook's login button and in IE 9 it throws client-side exception in all.js on Line 22: if(a.params)b.fbCallID=a.id;
Even after that exception I see the Facebook login screen and can log in, and in the main browser window I get the auth.login event, so I can live with that.
But, if I am already logged in to Facebook, I come to the page and click Facebook login button, I briefly see the empty popup window, then I get teh same client-side exception, and then I get no event in the main browser window, so I don't know if the user logged in so I can't redirect them to another page.
I tried the channelUrl trick but it didn't help.
Any suggestions what's going on?
I found this hack that fixed the issue for me; add this line right after you call FB.init():
// Hack to fix http://bugs.developers.facebook.net/show_bug.cgi?id=20168 for IE7/8/9
FB.UIServer.setLoadedNode = function (a, b) {
FB.UIServer._loadedNodes[a.id] = b;
};
The reason it is happening (from the websites and documents I have read, and believe me, I've read a LOT) is that IE refuses cross-site javascript, and it sees the all.js as crossing the sandbox border. A good discussion can be found here.
Some people say that adding the channel.html file works, but we have tried all flavors of that, and have not had any success. (Remember that the http or https must match the page sending the request.)
Microsoft makes reference to this same issue and their advice is to add the site to trusted sites (that doesn't help). Old advice (from last year) is to add CP="HONK" as your compact privacy policy, but I think that bug was fixed, and it was cookie-related.
What seems to be happening to us is that the login actually continues, and the callback gets called properly, but the main thread that should complete outside of the login call stops executing (because of the error). So, any functions outside the login fail to execute after the login call.
If anyone has a way to get IE to not throw the exception or to create a workaround for this issue, I am desperate to have it. Any info needed I will be happy to provide, but a sample is here:
enter code here
code before login here...
FB.login(function(response){
callback stuff here... This part fires.
});
main thread stuff here... This fails because of permission denied error.

WebClient.UploadData error: (401) Unauthorized

I'm getting this error... What is puzzling me is the fact that i do not have any type of security enabled for the page i'm invoking...
WebClient myWebClient = new WebClient();
myWebClient.UploadData(myUrl,"POST", myByteArray);
When i access directly to the page ( on ie ) it works fine, with the WebClient it's not working.
Anyone has a clue on what can be wrong?
IE supports integrated security, which will use your current login credentials as the username and password, so you don't have to manually enter it.
If you are using IE, use Firefox and see if you are prompted for a username and password. Or, in IE, you can go to Tools, Options, Advanced, and uncheck Integrated Windows Authentication.
Most likely, you'll have to configure the web application to support anonymous access, or you'll have to implement security in your WebClient.
If you are struggling to get to the bottom of it Fiddler might shed some light. You will have to manually edit your code to go through the Fiddler proxy, but once that's done you can compare the IE result to the code one.