Using Java:

WebElement webElement = driver.findElement(By.xpath(""));//You can use xpath, ID or name whatever you like
webElement.sendKeys(Keys.TAB);
webElement.sendKeys(Keys.ENTER);
Answer from Sachin Francis on Stack Overflow
๐ŸŒ
Selenium
selenium.dev โ€บ documentation โ€บ webdriver โ€บ actions_api โ€บ keyboard
Keyboard actions | Selenium
July 29, 2025 - package dev.selenium.actions_api; import dev.selenium.BaseChromeTest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.Platform; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; public class KeysTest extends BaseChromeTest { @Test public void keyDown() { driver.get("https://www.selenium.dev/selenium/web/single_text_input.html"); new Actions(driver) .keyDown(Keys.SHIFT) .sendKeys("a") .perform(); WebElement textField = driver.findElement(By
Discussions

How to press "TAB" then "ENTER" key in Selenium WebDriver using Java? - Stack Overflow
I am doing automation testing using java with Selenium WebDriver. I want to click on tabs. I would like to check tab functionality. I can use Tab key to get the button as below: WebElement webEle... More on stackoverflow.com
๐ŸŒ stackoverflow.com
November 15, 2017
python - Send multiple tab key presses with Selenium - Stack Overflow
Communities for your favorite technologies. Explore all Collectives ยท Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
๐ŸŒ stackoverflow.com
Press TAB and then ENTER key in Selenium WebDriver with Ruby - Stack Overflow
I am doing automated testing using Selenium WebDriver with Ruby. I need to click a button. I cannot get the button element by id or css or xpath as the button is transparent. I would like to use Ta... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Selenium Powershell Send 2 keys at once (open new tab)
carpenter ring growth spark aromatic cats hungry coherent rob north This post was mass deleted and anonymized with Redact More on reddit.com
๐ŸŒ r/PowerShell
6
5
November 14, 2018
๐ŸŒ
UI Vision
ui.vision โ€บ rpa โ€บ docs โ€บ selenium-ide โ€บ sendkeys-type
sendKeys and Type - Selenium IDE Commands Tutorial
Setting it to false can be useful, for example, for sending file paths like "c:\test\note.txt" (note the \n and \t in this string!). This RPA forum post has more details. ... The sendKeys command simulates keystroke events on the specified element, as though you typed the value key-by-key.
๐ŸŒ
Testsigma
testsigma.com โ€บ blog โ€บ test automation โ€บ selenium sendkeys: a detailed usage guide
Selenium SendKeys: A Detailed Usage Guide
June 28, 2025 - There are several special keys that you can use with the Selenium Sendkeys method to simulate more complex keyboard inputs, such as pressing the โ€œTabโ€ key, the โ€œEnterโ€ key, or the โ€œBackspaceโ€ key.
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to send control or enter or tab key in Selenium WebDriver (Selenium Interview Question #345) - YouTube
In this session, I have answered one of the Selenium Interview Questions i.e.How to send alt or shift or control or enter or tab key in Selenium WebDriver (S...
Published ย  June 30, 2023
Find elsewhere
๐ŸŒ
Automation Talks
automationtalks.com โ€บ home โ€บ selenium tutorial โ€บ how to use tab key (button) in selenium webdriver?
How to use tab key (button) in selenium WebDriver?
November 6, 2017 - Basically, you need to have instance of Actions class and then call sendKeys with TAB as TAB key. package learnAboutActionsClass; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import ...
๐ŸŒ
Quora
quora.com โ€บ How-do-I-use-tab-button-functionality-using-selenium
How to use tab button functionality using selenium - Quora
Answer (1 of 6): I am assuming you want to ask "How do I simulate pressing of Tab key using Selenium WebDriver?" Below are the steps to do this - 1. Locate the element on which you want to simulate the Tab key pressing. 2. Simulate the Tab key pressing. In terms of code - [code]WebElement inpu...
๐ŸŒ
Blogger
selenium-interview-questions.blogspot.com โ€บ 2014 โ€บ 02 โ€บ how-to-press-tab-key-in-selenium.html
Selenium Webdriver: How to press tab key in selenium webdriver in Java?
We can press TAB key or any other key in Selenium Web driver by 2 ways in Java. ... To use this method, you will have to import below class. import org.openqa.selenium.Keys; driver.findElement(By.name("name")).sendKeys(Keys.TAB);
๐ŸŒ
TOOLSQA
toolsqa.com โ€บ selenium-webdriver โ€บ keyboard-events-in-selenium
Keyboard Events and Mouse Events in Selenium Action Class
October 1, 2021 - Now, as we discussed, Selenium WebDriver provides two ways to send any keyboard event to a web element: ... Now let's try to understand in detail that if we want to automate the scenario as mentioned above of typing the letters in the capital (with SHIFT key pressed ), using the sendKeys() method of the WebElement class.
Top answer
1 of 4
3

Please see the solution that works with my example form

FormTab.html:

<!DOCTYPE html>
<html>
<body>
<form>
    First name:<br>
    <input type="text" name="firstname" value="Mickey">
    <br>
    Last name:<br>
    <input type="text" name="lastname" value="Mouse">
    <br><br>
    <input type="submit" name="submit" value="Submit">
</form>
<p>If you click "Submit", nothing happens.</p>
</body>
</html>

Java code:

WebDriver driver = new FirefoxDriver();

//Insert path to your file
driver.get("FormTab.html");

//Three example elements
WebElement firstField = driver.findElement(By.name("firstname"));
WebElement secondField = driver.findElement(By.name("lastname"));
WebElement submit = driver.findElement(By.name("submit"));

//Start with the first field
firstField.sendKeys();
//Verify that we in the first field
if(driver.switchTo().activeElement().equals(firstField))
    System.out.println("First element is in a focus");
else
    //Add Assertion here - stop execution
    System.out.println("ASSERTION - first element not in the focus");

firstField.sendKeys(Keys.TAB);

//Verify that we in the second field
if(driver.switchTo().activeElement().equals(secondField))
    System.out.println("Second element is in a focus");
else
    //Add Assertion here - stop execution
    System.out.println("ASSERTION - second element not in the focus");

secondField.sendKeys(Keys.TAB);

if(driver.switchTo().activeElement().equals(submit))
    System.out.println("Submit element is in a focus");
else
    //Add Assertion here - stop execution
    System.out.println("ASSERTION - submit element not in the focus");

//Click the button 
submit.click();

//Need be closed also in case the assertion - use @After
driver.close();
2 of 4
2

Try the below code.This is working fine.

        Actions builder = new Actions(driver);         
        builder.SendKeys(OpenQA.Selenium.Keys.Tab).Build().Perform();
        builder.Release().Perform();            
        builder.SendKeys(OpenQA.Selenium.Keys.Tab).Build().Perform();
        builder.Release().Perform();
๐ŸŒ
BrowserStack
browserstack.com โ€บ home โ€บ guide โ€บ how to press enter without element in selenium python?
How to Press Enter without Element in Selenium Python? | BrowserStack
May 30, 2025 - Here you can directly send the username value as the username text box is in focus using the send_keys method,then press tab to navigate to the password field and press enter on the login button.
๐ŸŒ
Google Groups
groups.google.com โ€บ g โ€บ selenium-users โ€บ c โ€บ NyYtBE4wmdM โ€บ m โ€บ 9umhiMDNNeIJ
sendKeys(Keys.TAB) no longer working in Firefox 26 and Selenium 2.39
Hi there, I'm populating several ... using sendKeys. I select the suggestion for each field by sending Keys.TAB, which both accepts the current suggestion and exposes the subsequent field. This no longer works properly after upgrading from Firefox 25.01 and selenium-server-st...
๐ŸŒ
MySkillPoint
myskillpoint.com โ€บ send-keyboard-keys-in-selenium-webdriver
SendKeys in Selenium WebDriver With Example - MySkillPoint
August 8, 2021 - Pressing Tab: Pressing the โ€œTabโ€ key. These are a few examples however, there could be many more as per the test scenario of the application. ... Type text โ€œabโ€ by pressing the โ€œSHIFTโ€ key.
๐ŸŒ
Wordpress
seleniumatfingertips.wordpress.com โ€บ tag โ€บ new-tab-in-selenium
New tab in selenium - Selenium at Fingertips - WordPress.com
You might have come across scenarios where you want to open a new browser tab or new browser window and perform some actions on newly opened tab or window. We will look at how we can achieve the same using Selenium WebDriver. element.sendKeys(Keys.CONTROL,โ€tโ€); element.sendKeys(Keys.CONTROL + โ€œtโ€); String chord = Keys.chord(Keys.CONTROL, โ€œtโ€); element.sendKeys(chord); String chord = Keys.chord(Keys.CONTROL + โ€œtโ€); element.sendKeys(chord); public class SendKeysAdvanced { public static void main(String[] args) throws Exception { WebDriver driver = new FirefoxDriver(); driver.mana
๐ŸŒ
Reddit
reddit.com โ€บ r/powershell โ€บ selenium powershell send 2 keys at once (open new tab)
r/PowerShell on Reddit: Selenium Powershell Send 2 keys at once (open new tab)
November 14, 2018 -

Hi,

I'm trying to find a way to send crtl + t.

I want to open a new tab and later switch between tabs.

I only find information for C#, but I think the way to write it is different in powershell.

Unfortunately I can't figure it out.

This is what I found for C#

//Open a new tab using Ctrl + t
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");
//Switch between tabs using Ctrl + \t
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"\t");

I have found how to send one key with powershell, but not 2.

This is working for one Tab press inside Google.com with powershell:

#load the web driver dll
Add-Type -path "C:\Program Files\WindowsPowerShell\Modules\Selenium\1.0\assemblies\WebDriver.dll"
#initiate a driver
$script:driver = New-Object OpenQA.Selenium.Firefox.FirefoxDriver
#specify an implicit wait interval
$null = $driver.Manage().Timeouts().ImplicitlyWait((New-TimeSpan -Seconds 5))
#browse to a website
$driver.Url = 'https://www.google.com/'

$tab = $driver.FindElementByXPath('/html[1]/body[1]/div[1]/div[3]/form[1]/div[2]/div[2]/div[1]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/input[1]')
$tab.SendKeys([OpenQA.Selenium.Keys]::tab)

There don't seem to be many resources for using selenium with powershell.

Any help is appreciated!

๐ŸŒ
BrowserStack
browserstack.com โ€บ home โ€บ guide โ€บ sendkeys in selenium webdriver
SendKeys in Selenium WebDriver | BrowserStack
December 31, 2024 - Selenium sendkeys help QAs automate test cases for form interactions on web-app. Learn to use sendkeys method in selenium with example to enter username & password.