How to use sendKeys() method to enter value into the email ID text field?

How to use sendKeys() method to enter email id into the email ID text field?

1 Like

Hey Michael,

You can use the following code snippet to do that:

WebElement emailField = driver.findElement(by.id(“useremail”));

emailField.sendKeys(“---your email id---”);

This will allow you to enter your email into the email ID text field.

4 Likes

Thanks shahzebh,

Can you also help me with the syntax/method to erase text.

2 Likes

Michael,

You can use the Selenium clear() method, which simply erases whatever text is entered in the text field.

You can further enter the text using the sendKeys() method as per your requirement.

Hope it helps!

You can go through this tutorial on Selenium SendKeys.

4 Likes

Hey michel if element.clear is not working then use following code before using sendkeys(entering anything in textbox)

While(! element.getattribute(“value”).equals("")){ Element.sendkeys(keys.Backspace); }

4 Likes