How to send text in capital letters into a text-box using Actions class in Selenium WebDriver?

We can send the text in capital letters (Upper case) in to a text box by using actions class of the selenium. Very simple.  First press the SHIFT key and then send the text which you want to convert to capital letter before sending to text box.
Send Capital letters to textbox using actions class in Selenium WebDriver
Below program illustrates the same –
package learnAboutActionsClass;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class SendTextInCapitalLetter {

 public static void main(String[] args) {
  // TODO Auto-generated method stub

  WebDriver driver = new FirefoxDriver();

  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);


  String TextToBeConvertAndSendInUpperCase = "Synchronization in Selenium";

  WebElement element = driver.findElement(By.xpath("//input[@class='search']"));

  Actions act = new Actions(driver);

  act.keyDown(element, Keys.SHIFT).sendKeys(TextToBeConvertAndSendInUpperCase).keyDown(element, Keys.SHIFT).build().perform();


Original Text was:  “Synchronization in Selenium”;
The text sent to the text box –
Hope this helps !!! post your questions if any.

Leave Comment

Your email address will not be published. Required fields are marked *

Looking for learning Framework Development from Scratch? Lookout for Detailed Framework Development videos on YouTube here -

Get the Framework code at Github Repo: