0

WatiN 支持重定向吗?

我正在尝试自动化与 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 = "some@mail.com";
         ie.TextField("password-oauthAuthorizeForm").Value = "password";
         ie.Button(Find.ByName("authorize")).Click();
         //ie.Forms[0].Submit();
    }
}

按下按钮,Internet Explorer 立即重定向到同一页面。表单提交具有相同的行为。

你怎么想的?那是WatiN问题还是linkedin守卫?

4

2 回答 2

1

当页面重定向到不同的页面时,我之前已经看到了这种行为。

所以你需要为新的 url 再次创建一个单独的 IE 对象

页面提交后

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

为新 URL 创建一个新的 watin 会话

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

我不知道有没有更好的方法可用,但这对我有用..

于 2010-02-18T11:53:22.260 回答
1

请注意,LinkedIn 的服务条款不允许您编写授权流程脚本。我们要求您让用户决定通过提供的表格授予或拒绝访问您的集成。

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

于 2010-02-19T06:50:55.700 回答