new window selenium python

import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

class GoogleOrgSearch(unittest.TestCase):

     def setUp(self):
         self.driver = webdriver.Firefox()

    def test_google_search_page(self):
         driver = self.driver
         driver.get("http://www.cdot.in")
         window_before = driver.window_handles[0]
         print window_before
         driver.find_element_by_xpath("//a[@href='http://www.cdot.in/home.htm']").click()
         window_after = driver.window_handles[1]
         driver.switch_to_window(window_after)
         print window_after
         driver.find_element_by_link_text("ATM").click()
         driver.switch_to_window(window_before)


    def tearDown(self):
    self.driver.close()

if __name__ == "__main__":
unittest.main()

4.5
4
Paul Ramshaw 100 points

                                    # Opens a new tab
self.driver.execute_script("window.open()")

# Switch to the newly opened tab
self.driver.switch_to.window(self.driver.window_handles[1])

4.5 (4 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
switch the selinum driver in python python selenium driver switch to driver.switch_to selenium python driver switch selenium python python selenium how to change driver how to switch to window in selenium python selenium python focus window switch_to.window selenium switch window python python selenium switch page python selenium swtich site python selenium get avilable windows python driver show switchto window switch_to_window python selenium depression switch_to_window python selenium switch window python switching to new window in selenium python selenium window handles python switch window using python list all windows selenium python how to switch driver to new window in selenium python python switch windows selenium python switch to window in the background switch to windows file open window using selenium python python switch to window selenium get window handles selenium python selenium howto use driver.switch_to.window() switch window selenium python python windows handler selenium focus window python switching windows python python selenium switch to window selenium driver switch_to.window hook browser.switch_to.main_window selenium python how to switch to new window in selenium using webdriver in python driver1.switch_to.window(driver1.window_handles[0]) manage selenum python windows driver.switch_to_window(window_name) selenium python switch_to main window switch windows using python selenium new window python python selenium driver move window to back selenium python .window() python switch window name before after driver.switchto().window python switch to window in selenium python python selenium second window driver.switch_to.window window_handles selenium python selenium switch to current window python driver.window_handles selenium selenium switch to main window python new window selenium python use of browser.window_handles browser.window_handles selenium get window handles python python selenium get open windows webdriver window handle python python selenium sub windows get window handle in selenium python python switch window how to change window in selenium in oython switch to other window in selenium python switch browser selenium python python selenium window handles python selenium open window with name how to switch by window name in selenium python how to switch window in selenium python selenium method to focus on new window python change window handle selenium python python switching windows how to change to an diffrent window with python python selenium switch between windows python switch to window selenium turn to new window selenium switch to window python how to change to another window that was just opened on a click selenium python how to switch windows in selenium python switch windows in selenium python in chromedriver switch window in selenium python how to run switch window in selenium python switch window in selenium pythin How to switch to new window in Selenium for Python? switch to new window selenium python selenium webdriver handle new window python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source