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");
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.
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.
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.
To enter text into the Text Fields and Password Fields, sendKeys() is the method available on the WebElement in Selenium.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With