views:

152

answers:

2

Does WatiN support redirects?

I'm trying to automate testing linked in integration library with WatiN.

// url like "https://api.linkedin.com/uas/oauth/authorize?oauth_token=ba826cd4-644a-4709-b2de-bedb7c8fb5b4"
 using (var ie = new IE(authorizationUrl)) 
 {
    if (ie.TextField("email-oauthAuthorizeForm").Exists 
           && ie.TextField("password-oauthAuthorizeForm").Exists)
    {
         ie.TextField("email-oauthAuthorizeForm").Value = "[email protected]";
         ie.TextField("password-oauthAuthorizeForm").Value = "password";
         ie.Button(Find.ByName("authorize")).Click();
         //ie.Forms[0].Submit();
    }
}

The button are pressed, and Internet Explorer redirects immediately to the same page. Form submit have the same behaviour.

What you think about it? Is that WatiN problem or linkedin guard?

+1  A: 

I have seen the behaviour earlier, when the page redirect to the different one.

So you need to create a seperate IE object again for the new url

After page submit

ie.Button(Find.ByName("authorize")).Click(); 

create a new watin session for the new URL

using (var ie = new IE(urredirectedurl))   
{ 
     //ur code
}

I dont know is there any better approaches available, but this works for me..

Cheers

Ramesh Vel
+1  A: 

Hi there,

Note that LinkedIn's Terms of Service do not allow you to script the authorization flow. We require you to let the user decide to grant or deny access to your integration via the form provided.

If it's automated test suites you're after I'd suggest authorizing an access token once and storing that with your test scripts.

Paul Lindner