Saturday, 14 February 2015

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 do click on button automatically in web browser. To click on button we need button locater string. To get locater string you need to install FireFox Element Locater Tool in Firefox. This article is very useful for automate website testing.

Here is example for this:

In this example first we open website 'www.google.com'. After that, we locate search textbox and search button ID locater string using FireFox Element Locater Add-on.

Now in C# code we create object of FireFoxDriver Class. You can also create object of other browsers. Now using 'FindElement' method of 'FireFoxDriver' Class object, we are finding search textbox and search button.

After finding search textbox we enter some text using 'SendKeys' method. After that, programmatically we are doing click on search button using 'Click' method.