Click Here to Download InsertTextInTextBox.zip
Using selenium C# webdriver API we are able to insert text in website textbox element automatically in web browser. This article is very useful for automate website testing.
To enter text in textbox we need locator string of that particular textbox. To get locator string you need to your FireFox Element Locator Add-on.
Here is example for insert text in textbox automatically:
In this example first we open website 'www.google.com'. After that, we locate search textbox using locator add-on. Now in C# code we create object of FireFoxDriver Class.
We are using 'FindElement' method of 'FireFoxDriver' Class object, in this object we are finding element using 'XPath'. We are using 'OpenQA.Selenium.By.XPath' method. After finding element we are using 'SendKeys' method to insert text in textbox.
In 'SendKeys' method's parameter pass your desire text or string. This method exist in 'OpenQA.Selenium.IWebDriver.ISearchContext.FindElement' class.
Selenium C# Code :
[Image : Open 'www.google.com' and enter text] :
Prerequiest to learn this article :
You need to learn these previous articles before learning this article.
Selenium Tool : Configure selenium tool for asp.net C# website or project in Visual Studio.
Selenium Tool : Download and Install WebDriver Element Locator Add-on.
Full Video :
Note :
If any runtime error occurred by running our downloaded project meaning
of that your browser version and Selenium API DLL version is not
matching. To resolve this issue you need to download latest Selenium C#
API DLLs from this link and paste downloaded DLLs into 'Bin'
folder of downloaded project. Or you can remove references of existing
DLLs references and add new DLLs references. You can learn this thing
from this link.
Using selenium C# webdriver API we are able to insert text in website textbox element automatically in web browser. This article is very useful for automate website testing.
To enter text in textbox we need locator string of that particular textbox. To get locator string you need to your FireFox Element Locator Add-on.
Here is example for insert text in textbox automatically:
In this example first we open website 'www.google.com'. After that, we locate search textbox using locator add-on. Now in C# code we create object of FireFoxDriver Class.
We are using 'FindElement' method of 'FireFoxDriver' Class object, in this object we are finding element using 'XPath'. We are using 'OpenQA.Selenium.By.XPath' method. After finding element we are using 'SendKeys' method to insert text in textbox.
In 'SendKeys' method's parameter pass your desire text or string. This method exist in 'OpenQA.Selenium.IWebDriver.ISearchContext.FindElement' class.
Selenium C# Code :
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Selenium; using OpenQA; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { OpenQA.Selenium.IWebDriver objFF = new OpenQA.Selenium.Firefox.FirefoxDriver(); objFF.Navigate(); objFF.Url = "http://www.google.com"; objFF.FindElement(OpenQA.Selenium.By.XPath("//input[@id='gbqfq']")).SendKeys("ASP.NET"); } }
[Image : Open 'www.google.com' and enter text] :
(To view original size image , click on image) |
Prerequiest to learn this article :
You need to learn these previous articles before learning this article.
Selenium Tool : Configure selenium tool for asp.net C# website or project in Visual Studio.
Selenium Tool : Download and Install WebDriver Element Locator Add-on.
Full Video :
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteselenium training in chennai
java training in chennai
Nice post,and good information Thanks for sharing further check it once at
ReplyDelete.NET Online Training Hyderabad
Thanks for sharing this information.
ReplyDeleteBest Digital Marketing Services Provider in Coimbatore
Best Website Development Company in Coimbatore
Best Search Engine service provider in Coimbatore