I want to open a new tab in the current session of the Selenium WebDriver using Python. I found this link for Java but could not convert it to Python. Can you help?
            Asked
            
        
        
            Active
            
        
            Viewed 1,408 times
        
    2 Answers
2
            The link that you have posted uses a keyboard shortcut to open the new tab. You can try manually using Ctrl+t this shortcut opens a new tab in the current browser. So here is what we have to do:
Locate an element using Web-Driver and send it the shortcut (Ctrl+t).
import from selenium.webdriver.common.keys import Keys
driver.find_element_by_xpath('xpath_to_one_element').send_keys(Keys.CONTROL +"t")
 
    
    
        L Y E S  -  C H I O U K H
        
- 4,765
- 8
- 40
- 57
 
    
    
        Madan
        
- 51
- 3
0
            
            
        Seems like a duplicate of this, here is what they suggest:
Open web in new tab Selenium + Python
driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 't') 
On Windows you would use CONTROL + T
 
    
    
        chasezimmy
        
- 46
- 1
- 8
