how to switch driver in python selenium

Solutions on MaxInterview for how to switch driver in python selenium by the best coders in the world

showing results for - "how to switch driver in python selenium"
Sofie
13 May 2020
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()
queries leading to this page
selenium window handles pythondriver window handles seleniumswitch to other window in selenium pythonswitch to window python selenium depressionswitch browser selenium pythonselenium python switch to main windowswitch windows using pythonpython selenium driver switch toswitch windows in selenium python in chromedriverhow to change to an diffrent window with pythonselenium webdriver handle new window pythonchange window handle selenium pythonhow to switch to window in selenium pythonswitch to window in selenium pythonselenium howto use driver switch to window 28 29python selenium switch to windowswitch window pythonpython selenium switch between windowsswitch window in selenium pythonselenium python switch to window in the backgroundwebdriver window handle pythondriver switch selenium pythondriver switch to windowselenium python focus windowpython selenium switch topython switch to windowselenium turn to new windowpython windows handlerhow to run switch window in selenium python python selenium how to change driverselenium switch to window pythonswitch to windows file open window using selenium pythonswitch to windownew window selenium pythonpython selenium sub windowspython switch window name before afterpython selenium swtich sitepython switching windowsselenium switch window pythonselenium driver switch to window hookselenium switch to current window pythondriver switch to window 28window name 29switch window selenium pythonswitch window using pythonmanage selenum python windowspython switch windowhow to change window in selenium in oythonpython driver show switchto windowpython switch windowspython selenium get open windowshow to switch to new window in selenium using webdriver in pythonswitching to new window in selenium pythonswitch the selinum driver in pythonhow to switch driver to new window in selenium pythonhow to switch window in selenium pythonget window handles selenium pythonselenium switch to main window pythonuse of browser window handleslist all windows selenium pythondriver switch to selenium pythonswitch to new window selenium pythonpython selenium open window with nameswitch to window python seleniumdriver1 switch to window 28driver1 window handles 5b0 5d 29selenium method to focus on new window pythonpython selenium window handlespython switch to window seleniumhow to switchto selenium pythonhow to switch by window name in selenium pythonswitching windows pythonselenium focus window pythonhow to change to another window that was just opened on a click selenium pythonselenium new window pythonswitch window in selenium pythinpython selenium driver move window to back 09browser switch to main window selenium python python selenium second windowbrowser window handleswindow handles selenium pythonhow to switch windows in selenium pythonget window handle in selenium pythonselenium get window handles pythondriver switchto 28 29 window pythonhow to switch to new window in selenium for python 3fselenium python window 28 29python selenium switch pagepython selenium get avilable windowspython selenium switch to how to switch driver in python selenium