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.
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); driver.manage().window().maximize(); driver.navigate().to("http://automationtalks.com"); 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.