在Mac上使用Selenium WebDriver在Firefox中打开新选项卡 [英] Open new tab in Firefox using Selenium WebDriver on Mac
问题描述
$ b $ ol
唯一不行的是步骤3.我找不到如何打开新标签页。我在这里找到了这个:如何打开一个新的标签使用Selenium WebDriver与Java?不过,我在本地(即用可见的显示器)在我的Mac上进行了测试,用于调试目的,我看到Firefox浏览器(在创建驱动程序对象时打开)没有打开任何选项卡按照SO线程上的描述进行操作。所以我在这里试过:
$ b $ pre $ driver = webdriver.Firefox()
driver.get(https:// )
body = driver.find_element_by_tag_name(body)
body.send_keys(Keys.CONTROL +'t')
正如我所说,这对我不起作用。那么,如何才能打开制表符?我使用Selenium 2.39(pip install selenium)和Python 2.7。
在OSX上打开一个新选项卡的组合键是Command + T,所以你应该使用
$ $ p $ body $。 c $ c>
I just installed Selenium Web Driver and tried it out. It works great. My use case can be describe as followed:
- Start Firefox on a server with pseudo X server (Xvfb)
- New Driver.Firefox() object
- Open 10 tabs and load a webpage in each tab
- Retrieve the html from all loaded pages
The only step that is not working is step 3. I can not find out how to open new tabs. I found this here on SO : How to open a new tab using Selenium WebDriver with Java? However, I tested this locally (i.e. with visible display) on my Mac for debugging purpose and I saw that the Firefox browser (which was opened when creating the driver object) does not open any tabs when doing as described on the SO thread. So I tried this here:
driver = webdriver.Firefox()
driver.get("https://stackoverflow.com/")
body = driver.find_element_by_tag_name("body")
body.send_keys(Keys.CONTROL + 't')
As I said, it does not work for me. So, how else is it possible to open tabs? I use Selenium 2.39 (pip install selenium) and Python 2.7.
the key combination to open a new tab on OSX is Command+T, so you should use
body.send_keys(Keys.COMMAND + 't')
这篇关于在Mac上使用Selenium WebDriver在Firefox中打开新选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!