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
#1
It seems simple enough, and I've tried a few different ways but none of them have worked so far. To Open a new tab in Chrome (which works the same way when done manually by hand in Selenium's Browser) you hold "CONTROL" and press "T".
These are the modules I'm working with:
>>> from selenium import webdriver
>>> driver = webdriver.Chrome()
>>> from selenium.webdriver.common.action_chains import ActionChains
>>> from selenium.webdriver.common.keys import Keys
Here is what I've tried so far with no results:
>>> ActionChains(driver).key_down(Keys.CONTROL).send_keys('t').key_up(Keys.CONTROL).perform()
>>> # THIS DOES NOT GIVE AN ERROR, BUT IT ALSO DOES NOTHING
>>>
>>> menu = driver.find_element_by_tag_name('body')
>>> actions = ActionChains(driver)
>>> actions.move_to_element(menu).key_down(Keys.CONTROL).send_keys('t').key_up(Keys.CONTROL).perform()
>>> # THIS GIVES NO ERROR ASWELL, BUT IT ALSO DOES NOTHING
>>> 
>>> driver.find_element_by_tag_name("body").send_keys(Keys.CONTROL + 't')
>>> # THIS GIVES NO ERROR AND DOES NOTHING. I SUSPECT IT PRESSES ONE KEY, RELEASES IT, THEN PRESSES THE OTHER. 
Neither of these ways give error, but neither works. Anyone have any ideas or advice, please leave a comment. Thank you.
Reply


Messages In This Thread
Need Help Opening A New Tab in Selenium - by HiImNew - Jan-14-2018, 08:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Web Page not opening while web scraping through python selenium sumandas89 4 10,206 Nov-19-2018, 02:47 PM
Last Post: snippsat
  Selenium opening pdf in new window test 6 11,151 Sep-15-2018, 07:55 PM
Last Post: test
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 3,709 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