WatiN 无法通过 alt 找到元素
我有一个页面包含以下代码行
<INPUT border=0 type=image alt="Use a password" name="SUBMIT-password.pss" src="docs/pics/en-us/useapassword_button.jpg">
我的代码是
using (var browser = new IE(path))
{
browser.Button(Find.ByAlt("Use a password")).Click();
Assert.IsTrue(browser.ContainsText("WatiN"));
}
I have a page that has the following line of code
<INPUT border=0 type=image alt="Use a password" name="SUBMIT-password.pss" src="docs/pics/en-us/useapassword_button.jpg">
My code is
using (var browser = new IE(path))
{
browser.Button(Find.ByAlt("Use a password")).Click();
Assert.IsTrue(browser.ContainsText("WatiN"));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
browser.Image
而不是browser.Button
,我使用您的 HTML 代码段设置了一个测试文件,以下内容按您的预期工作。如果我没记错的话,在WatiN 1.?您可以使用 Button,但在 WatiN 2.1 中您使用 Image 类。
以上是在WatiN 2.1、IE9、Win7上测试的。
Instead of
browser.Button
, usebrowser.Image
I setup a test file with your HTML snippet and the following works as you'd expect. If I'm remembering correctly, in WatiN 1.? you'd use Button, but in WatiN 2.1 you use the Image class.
The above is tested on WatiN 2.1, IE9, Win7.