- Create virtual environment and activate it (optional)
- install selenium with $ pip install selenium
- Download chrome driver (or geako for firefox or ghostdriver for phanotm)
- Use following code to get started
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome('./chromedriver')
driver.execute_script('window.open()')
driver.close() // close first window
driver.close() // this will reuslt in error
// to avoide error first switch to window
driver.switch_to_window(window_name) // dont know how to get this window_name
// now close window with driver.close() or get new document with driver.get()
driver.close() or driver.get('http://example.com')
// get a list of all open windows
driver.window_handles
[u'CDwindow-8fbbbee1-0c2f-4a01-aa5b-02b655f5d77f', u'CDwindow-2a7323e8-f540-4703-a56f-086d4bc068e3']