Selenium 一次有多个标签 [英] Selenium multiple tabs at once

查看:25
本文介绍了Selenium 一次有多个标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Selenium,想知道是否可以同时使用多个 TABS?我不想使用多个浏览器实例(即 IE 双关语的 2 个副本).如果不可能,如何在按顺序运行的单个选项卡之间切换?

I'm working with Selenium, and am wondering if it's possible to use multiple TABS at once? I do not want to use multiple browser instances (i.e., 2 copies of IE pun). IF IT IS NOT possible, how would one go about switching between individual tabs, that are running sequentially?

谢谢!

推荐答案

如果有打开新窗口/选项卡的链接,那么你可以使用 driver.switchTo().window();

If there is a link that opens up a new window/tab, then you can use driver.switchTo().window();

但是,如果您想在多个窗口上运行某些东西,那么我建议您拥有多个 webdriver 实例.它更易于管理且受支持(有打开新选项卡/窗口的变通方法,例如按下打开新窗口的热键,但不支持).

However, if you want to run something on multiple windows, then I recommend having multiple instances of webdriver. It is much easier to manage, and is supported (There are workarounds on opening a new tab/window, such as pressing a hotkey that opens a new window, but they aren't supported).

如果您想让多个线程都作用于同一个驱动程序实例,但不同的选项卡,这是不可能的.

If you are wanting to have multiple threads all act on the same driver instance, but different tabs, that is NOT possible.

这篇关于Selenium 一次有多个标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆