如何使用 WatiN 在 IE 中打开新选项卡?

发布于 2024-10-08 20:18:18 字数 353 浏览 0 评论 0原文

如何打开选项卡并转到“http://anotherwisite.com”?我尝试了这个:(

ie = new WatiN.Core.IE("https://somewebsite.com", true);
ie.TextField(WatiN.Core.Find.ByName("user")).TypeText(User.getName());
ie.TextField(WatiN.Core.Find.ByName("password")).TypeText(User.getPassword());
ie.Button(WatiN.Core.Find.Any).Click();

上面的代码打开一个 IE 并登录该人)

How can I open a tab and go to "http://anotherwisite.com"? I tried this:

ie = new WatiN.Core.IE("https://somewebsite.com", true);
ie.TextField(WatiN.Core.Find.ByName("user")).TypeText(User.getName());
ie.TextField(WatiN.Core.Find.ByName("password")).TypeText(User.getPassword());
ie.Button(WatiN.Core.Find.Any).Click();

(the above code opens an IE and log the person in)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

浅浅 2024-10-15 20:18:18

我可以使用 Watin 代码打开一个新选项卡并打开新页面

var browser1 = new FireFox("http://www.omda.com");
SendKeys.SendWait("^{t}");
browser1.GoTo("http://www.omda2.com");

我在 Firefox 中使用键盘 CTRL+T。

I can open a new Tab and open new page with Watin

Code:

var browser1 = new FireFox("http://www.omda.com");
SendKeys.SendWait("^{t}");
browser1.GoTo("http://www.omda2.com");

I use the keyboard, CTRL+T in Firefox.

情绪 2024-10-15 20:18:18

WatiN 中没有内置方法可以做到这一点。

There is no built-in method in WatiN to do that.

金兰素衣 2024-10-15 20:18:18
System.Windows.Forms.SendKeys.SendWait("^{t}"); 
Thread.Sleep(400); 
//this is the new browser instance
var newTab = Browser.AttachTo<IE>(Find.ByTitle(string.Empty)); 
System.Windows.Forms.SendKeys.SendWait("^{t}"); 
Thread.Sleep(400); 
//this is the new browser instance
var newTab = Browser.AttachTo<IE>(Find.ByTitle(string.Empty)); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文