In this article , we will see the functions needed for inserting data in a text box.
Usually the input text fields takes data and send request to server(i.e.- Log In page).
For this , we have to declear an element outside of method.
private IWebElement element;
Now inside any method , (for user name input text box )
-To find the element for taking username as input (in here txtUserName).
element = driver.FindElement(By.Id("txtUserName"));
-To clear existing or inputted text
element.Clear();
-To write user name "Shantonu"
element.SendKeys("Shantonu");
In the same way we can insert a password
And then, find the button and then
-To click the button
element.Click();
So, finally the full code will be
element = driver.FindElement(By.Id("txtUserName"));
element.Clear();
element.SendKeys("Shantonu");
element = driver.FindElement(By.Id("txtPassword"));
element.Clear();
element.SendKeys("123456");
element = driver.FindElement(By.Id("btnSignIn"));
element.Click();
Note - I use C# code.
Usually the input text fields takes data and send request to server(i.e.- Log In page).
For this , we have to declear an element outside of method.
private IWebElement element;
Now inside any method , (for user name input text box )
-To find the element for taking username as input (in here txtUserName).
element = driver.FindElement(By.Id("txtUserName"));
-To clear existing or inputted text
element.Clear();
-To write user name "Shantonu"
element.SendKeys("Shantonu");
In the same way we can insert a password
And then, find the button and then
-To click the button
element.Click();
So, finally the full code will be
element = driver.FindElement(By.Id("txtUserName"));
element.Clear();
element.SendKeys("Shantonu");
element = driver.FindElement(By.Id("txtPassword"));
element.Clear();
element.SendKeys("123456");
element = driver.FindElement(By.Id("btnSignIn"));
element.Click();
Note - I use C# code.