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')