Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Webdriver: Entering text into text field

When I enter text into the text field it gets removed.

Here is the code:

String barcode="0000000047166";  WebElement element_enter = _driver.findElement(By.xpath("//*[@id='div-barcode']"));  element_enter.findElement(By.xpath("//html/body/div[1]/div[3]/div[1]/form/div/div/input")).sendKeys("barcode"); 
like image 212
Adnan Ghaffar Avatar asked Oct 02 '13 12:10

Adnan Ghaffar


People also ask

How do I put text in a text box in Selenium?

We can type in a textbox using Selenium webdriver. We shall use the sendKeys() method to type in the edit box. It is an in-built method in Selenium. Let us consider a text box where we shall enter some text.

How do you enter and enter text in Selenium?

We can type Enter/Return key in Selenium. We shall use the sendKeys method and pass Keys. ENTER as an argument to the method. Also, we can use pass Keys.

How do you enter a character one by one into a text field in Selenium Webdriver?

Simply pass your input as such and have a go with it. driver. findElement(By.id("element")). sendKeys("Field Input Text"); sendKeys("Field Input Text") --> It will directly drop the text in the text field.

How do you type in a field in Selenium?

To enter text into the Text Fields and Password Fields, sendKeys() is the method available on the WebElement in Selenium.


1 Answers

Agree with Subir Kumar Sao and Faiz.

element_enter.findElement(By.xpath("//html/body/div[1]/div[3]/div[1]/form/div/div/input")).sendKeys(barcode); 
like image 154
Eshan Liyanagama Avatar answered Sep 23 '22 23:09

Eshan Liyanagama