开发者

Web Automation Watin Problem

I'm using watin to log into AOL Lifestream and get all the comments on my current lifestreams.

I am using Watin and IE to log in. The problem is it don't seem to find the form elements on the login page even though they are there.

Here is my code 开发者_高级运维to find and fill in the form elements:

// Sign in
        IE ie = new IE("http://lifestream.aol.com/");
        ie.WaitForComplete();

        // Log the user in or out
        if (ie.Element(Find.ById("account_dd")).Exists)
        {
            ie.GoTo("http://lifestream.aol.com/logout");
        }
        else
        {
            ie.Link(Find.ById("signInLink")).Click();
            ie.TextField(Find.ById("lgnId1")).Value = txtUsername.Text;
            ie.TextField(Find.ById("pwdId1")).Value = txtPassword.Text;
            ie.Button(Find.ById("submitID")).Click();
        }

The form elements are there because I can view them with Firebug. They seem to be generated with Javascript but they should still be in the DOM right?

Even when I check if they exist it comes back negative. Any help?


The login controls are inside an iframe element with id=loginframe. Change your code in the else branch like this:

var frame = ie.Frame("loginframe");

frame.TextField(Find.ById("lgnId1")).Value = txtUsername.Text;
frame.TextField(Find.ById("pwdId1")).Value = txtPassword.Text;
frame.Button(Find.ById("submitID")).Click();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜