Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I send special characters via SendKeys?

I'm trying to fill out a form in Selenium2.

One input has an autocomplete that I want to close, preferably by sending esc after the search term. I.e. something like driver.FindElement(By.Id("InputWithAutocomplete")).SendKeys("SearchTerm/ESC");

Keys that I would also like to send include del and ctrl+ a.

Is there a list of special characters that I can use?

I'm using Selenium for .NET 2.8 with the FirefoxDriver.

like image 707
kalyfe Avatar asked Oct 24 '11 12:10

kalyfe


People also ask

Can we use sendKeys on select elements?

sendKeys command does not work with Select elements and the only way to automate selection option is by using javascript.

What is sendKeys method?

sendkeys() is a method in Selenium that allows QAs to type content automatically into an editable field while executing any tests for forms. These fields are web elements that can be identified using locators like element id, name, class name, etc.

What is alternate to sendKeys?

We can input text in the text box without the method sendKeys with thehelp of the JavaScript Executor. Selenium executes JavaScript commands with the help of the executeScript method.


1 Answers

Try this:

WebElement list1;    
list1=firefoxDriver.findElement(By.name("lst")); 
list1.sendKeys(Keys.CONTROL);
like image 84
Asiq Ahamed Avatar answered Sep 29 '22 09:09

Asiq Ahamed