Ctrl + t - Can't open new tab in Selenium + Firefox Python


Wren

Has Selenium removed any functionality?

Goal: Open a new tab like "Ctrl+t"

environment:

  • Windows 7
  • Firefox 68
  • Python 3.7

The following two scripts are unresponsive:

# 1 
dr.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
# 2 
ActionChains(dr).key_down(Keys.CONTROL).send_keys('t').key_up(Keys.CONTROL).perform()

Some instructional videos from 3-4 years ago show the following script, but it doesn't seem to me

friend

You can open new tabs by:

  • SendKey method

    Mac OS

    dr.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 't')

    other operating systems

    dr.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')

  • way of action

    ActionChains(dr).key_down(Keys.CONTROL).send_keys('t').key_up(Keys.CONTROL).perform()

  • ExecuteScript method

    dr.execute_script("window.open('','_blank');")

    or use a specific url

    dr.execute_script("window.open('URL');")

-renew-

If your problem is to switch to a specific tab:

Before performing the operation, process the current label with the following command:

first_tab = dr.window_handles[0]

Then do the action that will take you to the new tab page. possible .clickaction.

Add some sleep to wait for a new tab to load dr.implicitly_wait(....).

Handle new tab windows with:

second_tab = dr.window_handles[1]

Now you can switch to the desired tab:

dr.switch_to.window(first_tab / second_tab)

Hope this helps.

Related


Ctrl + t - Can't open new tab in Selenium + Firefox Python

Wren Has Selenium removed any functionality? Goal: Open a new tab like "Ctrl+t" environment: Windows 7 Firefox 68 Python 3.7 The following two scripts are unresponsive: # 1 dr.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't') # 2 ActionChains(dr

AngularJS-Firefox can't open blob url in new tab

free life My following code works fine in Chrome and IE. The user clicks on the anchor tag and executes the code, then the pdf file is rendered in a new tab with the url blob: http://localhost:57389/5aee262a-8bc9-4943-b67f-7b76aeef4b99 vme.loadAttachment = fun

AngularJS-Firefox can't open blob url in new tab

free life My following code works fine in Chrome and IE. The user clicks on the anchor tag and executes the code, then the pdf file is rendered in a new tab with the url blob: http://localhost:57389/5aee262a-8bc9-4943-b67f-7b76aeef4b99 vme.loadAttachment = fun

AngularJS-Firefox can't open blob url in new tab

free life My following code works fine in Chrome and IE. The user clicks on the anchor tag and executes the code, then the pdf file is rendered in a new tab with the url blob: http://localhost:57389/5aee262a-8bc9-4943-b67f-7b76aeef4b99 vme.loadAttachment = fun

AngularJS-Firefox can't open blob url in new tab

live freely My following code works fine in Chrome and IE. The user clicks on the anchor tag and executes the code, then the pdf file is rendered in a new tab with the url blob: http://localhost:57389/5aee262a-8bc9-4943-b67f-7b76aeef4b99 vme.loadAttachment = f

AngularJS-Firefox can't open blob url in new tab

live freely My following code works fine in Chrome and IE. The user clicks on the anchor tag and executes the code, then the pdf file is rendered in a new tab with the url blob: http://localhost:57389/5aee262a-8bc9-4943-b67f-7b76aeef4b99 vme.loadAttachment = f

Selenium C# Open "New" tab CTRL+T doesn't work with CHROME

crush static void Main() { IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("http://google.com"); IWebElement body = driver.FindElement(By.TagName("body")); body.SendKeys(Keys.Control + "t"); } This is the code I'm trying to

Selenium C# Open "New" tab CTRL+T doesn't work with CHROME

crush static void Main() { IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("http://google.com"); IWebElement body = driver.FindElement(By.TagName("body")); body.SendKeys(Keys.Control + "t"); } This is the code I'm trying to

Selenium C# Open "New" tab CTRL+T doesn't work with CHROME

crush static void Main() { IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("http://google.com"); IWebElement body = driver.FindElement(By.TagName("body")); body.SendKeys(Keys.Control + "t"); } This is the code I'm trying to

Selenium C# Open "New" tab CTRL+T doesn't work with CHROME

crush static void Main() { IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("http://google.com"); IWebElement body = driver.FindElement(By.TagName("body")); body.SendKeys(Keys.Control + "t"); } This is the code I'm trying to

Selenium C# Open "New" tab CTRL+T doesn't work with CHROME

crush static void Main() { IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("http://google.com"); IWebElement body = driver.FindElement(By.TagName("body")); body.SendKeys(Keys.Control + "t"); } This is the code I'm trying to

Selenium C# Open "New" tab CTRL+T doesn't work with CHROME

crush static void Main() { IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("http://google.com"); IWebElement body = driver.FindElement(By.TagName("body")); body.SendKeys(Keys.Control + "t"); } This is the code I'm trying to

Allow Ctrl+T to open new tabs on all websites in Firefox

Martin J.H In Firefox, some websites and some plugins seem to "catch" the "control" key, so when I try to open a new tab with Ctrl+ T, nothing happens - or worse, something unexpected happens. example: On the Codecademy site, when editing code, Ctrl+ has no ef

Allow Ctrl+T to open new tabs on all websites in Firefox

Martin J.H In Firefox, some websites and some plugins seem to "catch" the "control" key, so when I try to open a new tab with Ctrl+ T, nothing happens - or worse, something unexpected happens. example: On the Codecademy site, when editing code, Ctrl+ has no ef

Selenium doesn't follow click to open new tab

Anonymous 0441 For a long time I had a problem using selenium to find the button I was looking for on the page. After a week, I had a "nice" idea to check the url where selenium was searching for the button. Fake me, this is the wrong url. So the problem is, s

Selenium Python can't access site in Firefox

double bass my code: import selenium from selenium import webdriver from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.keys import Keys import time, sys, datetime, calendar, os browser = webdriver.Firefox() loginURL

Selenium Python can't access site in Firefox

double bass my code: import selenium from selenium import webdriver from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.keys import Keys import time, sys, datetime, calendar, os browser = webdriver.Firefox() loginURL

C# Selenium - Can't get element in new tab

David Ariko I have some code that clicks a link on a webpage that opens a new tab and automatically switches the view to the new tab. When I try to select an element from this new web page, I get an error, even though the element really doesn't exist. Most of

C# Selenium - Can't get element in new tab

David Ariko I have some code that clicks a link on a webpage that opens a new tab and automatically switches the view to the new tab. When I try to select an element from this new web page, I get an error, even though the element really doesn't exist. Most of

C# Selenium - Can't get element in new tab

David Ariko I have some code that clicks a link on a webpage that opens a new tab and automatically switches the view to the new tab. When I try to select an element from this new web page, I get an error, even though the element really doesn't exist. Most of