1import unittest
2from selenium import webdriver
3from selenium.webdriver.common.keys import Keys
4from selenium.webdriver.common.by import By
5
6class GoogleOrgSearch(unittest.TestCase):
7
8 def setUp(self):
9 self.driver = webdriver.Firefox()
10
11 def test_google_search_page(self):
12 driver = self.driver
13 driver.get("http://www.cdot.in")
14 window_before = driver.window_handles[0]
15 print window_before
16 driver.find_element_by_xpath("//a[@href='http://www.cdot.in/home.htm']").click()
17 window_after = driver.window_handles[1]
18 driver.switch_to_window(window_after)
19 print window_after
20 driver.find_element_by_link_text("ATM").click()
21 driver.switch_to_window(window_before)
22
23
24 def tearDown(self):
25 self.driver.close()
26
27if __name__ == "__main__":
28unittest.main()
1# Opens a new tab
2self.driver.execute_script("window.open()")
3
4# Switch to the newly opened tab
5self.driver.switch_to.window(self.driver.window_handles[1])