Skip to main content
 首页 » 编程设计

c#之华庭;通过 id 获取元素不起作用

2024年02月23日14xiaohuochai

我正在尝试将数据放入隐藏输入内的文本区域,但 watin 没有找到它。

当我搜索输入时,我的程序会显示:

 var ie = new WatiN.Core.IE("http://facebook.com", true); 
 ie.ClearCookies();                                  ie.TextField(WatiN.Core.Find.ById("email")).TypeText(textBoxUsername.Text);                        ie.TextField(WatiN.Core.Find.ById("pass")).TypeText(textBoxPassword.Text); 
 ie.Button(WatiN.Core.Find.ByValue("Login")).Click(); 
 ie.Link(WatiN.Core.Find.ByText("Status")).Click();                  
                    ie.TextField(WatiN.Core.Find.ById("u362110_11")).TypeText(textBoxPassword.Text); 

异常

Could not find INPUT (hidden) or INPUT (password) or INPUT (text) or INPUT (textarea) or TEXTAREA element tag matching criteria: Attribute 'id' equals 'u493403_13' at http://www.facebook.com/home.php 

请您参考如下方法:

通过按名称搜索替换 id 使其工作,因为 id 是动态的并且一直在变化