How To Enter The Value In TextBox Using Selenium Webdriver

.
Question :How To type In Textbox field Using Selenium Webdriver with Java ?

Answer:
By using sendkeys() method we type in textbox using selenium webdriver.

sendkeys()
In selenium webdriver sendkeys() is a predefined method which is used to type the value in textbox field.

Syntax
sendkeys();

Example of sendkey method 

driver.findElement(By.id("pass")).sendKeys("abc@123456");

Selenium Code To type in text box using java

package automation;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class SendKeys
 {
 public static void main(String[] args)
 {
System.setProperty("webdriver.chrome.driver","D:\\abc\\Software\\chromedriver.exe");
WebDriver drivernew ChromeDriver(); //Launch Chrome browser 
driver.get("https://facebook.com");  //open the URL
driver.findElement(By.id("email")).sendKeys("sandeepkumar@gamil.com"); 
driver.findElement(By.id("pass")).sendKeys("abc@123456");
}
}

Explanation :
In Above code we have write the code to enter the username and password in facebook login page .
1) First it will Launch the Chrome Browser.
2) Then it enter the url and redirect it to the main login page.
3) Then it will enter the url.
4) Then password .


In this tutorial we learn how to Enter the value in text box in selenium webdriver .Hope this tutorial helpful for you ðŸ˜Š

Thanks & Regards 
Sandeep Yadav

Important Tags:
How to enter the value in textfied , How to type in text box in selenium , how to automate the textbox , how to enter the value in textbox in selenium webdriver using java


How To Enter The Value In TextBox Using Selenium Webdriver

Post a Comment

0 Comments