I'm doing remote web crawling and scraping, and hoping not to reload a new browser window for every link on one page.
The problem is that new tabs are not opening up with my Firefox web driver.
Here's what I've tried:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from pyvirtualdisplay import Display
# launch our headless display
display = Display(visible=0, size=(800, 600))
display.start()
# launch our web driver and get a page
browser = webdriver.Firefox()
browser.get("http://www.google.com/")
# try to open a new tab
ActionChains(browser).key_down(Keys.CONTROL).send_keys("t").key_up(Keys.CONTROL).perform()
# this should print 2, but it prints 1, because new tab not opened
print len(browser.window_handles)
# clean up everything
browser.quit()
display.stop()
Specifications:
- Ubuntu 14.04.2
- Python 2.7.6
- Selenium 2.47.1
- PyVirtualDisplay 0.1.3