WatiN 无法通过 alt 找到元素

发布于 2025-01-05 07:26:39 字数 355 浏览 1 评论 0原文

我有一个页面包含以下代码行

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘦怹 2025-01-12 07:26:39

使用 browser.Image 而不是 browser.Button

我使用您的 HTML 代码段设置了一个测试文件,以下内容按您的预期工作。如果我没记错的话,在WatiN 1.?您可以使用 Button,但在 WatiN 2.1 中您使用 Image 类。

Console.WriteLine(browser.Image(Find.ByAlt("Use a password")).Name);

以上是在WatiN 2.1、IE9、Win7上测试的。

Instead of browser.Button, use browser.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.

Console.WriteLine(browser.Image(Find.ByAlt("Use a password")).Name);

The above is tested on WatiN 2.1, IE9, Win7.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文