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 :
myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance
ReplyDeleteI am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts. Python Projects for Students Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account. Project Center in Chennai
DeleteThe blog you have shared is very much helpful to know more about the selenium. Thanks for your information about the selenium.
ReplyDeleteselenium testing training
selenium testing course
selenium training classes
selenium classes
selenium training course
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
The article seems to be more informative. This is more helpful for our selenium training in chennai Thanks for sharing
ReplyDeleteHi, I am getting error while execute Sendkeys in selenium after finding element using XPath. Below are the code statements,
ReplyDeleteIWebElement objElement = ((IWebDriver)clsRunConfiguration.objBrowser).FindElement(By.XPath(sDOMXPath));
objElement.SendKeys(sValueToBeSet); //Error is "Invalid Argument, text must be string\n"
Need urgent help to resolve this issue.
Regards,
Nikunj
Very nice blog and articles.
ReplyDeleteinternship request letter | Internship completion letter | internship companies | internship resume objective | internship application letter | Internship with training | internship email | internship experience | What internship means | Internship acknowledgement
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