Python Forum
Need Help Opening A New Tab in Selenium
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help Opening A New Tab in Selenium
#3
>>> driver.execute_script("window.open('');")
This actually did switch focus to the new window it created. Thank you again metulburr! :)

That one line was all I needed.

Edit: I realized what you meant by the driver itself switching tab focus. I created a list of window handles and told the driver to go to the last element in the list as this was the most recently opened tab. Like diz:
>>> driver.execute_script("window.open('');")
>>> Window_List = driver.window_handles
>>> driver.switch_to_window(Window_List[-1])
Reply


Messages In This Thread
RE: Need Help Opening A New Tab in Selenium - by HiImNew - Jan-15-2018, 05:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Web Page not opening while web scraping through python selenium sumandas89 4 10,157 Nov-19-2018, 02:47 PM
Last Post: snippsat
  Selenium opening pdf in new window test 6 10,989 Sep-15-2018, 07:55 PM
Last Post: test
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 3,665 Nov-03-2017, 08:41 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020