Saturday, 14 February 2015

Click Here to Download ClickOnButtonUsingSeleniumWebDriverTool.zip

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.

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 OpenQA;
using Selenium;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnOpenBrowser_Click(object sender, EventArgs e)
    {
        string STR_IE_DRIVER = Server.MapPath("EXEFiles");

        OpenQA.Selenium.IWebDriver objFF = new OpenQA.Selenium.Firefox.FirefoxDriver();
        objFF.Navigate();
        objFF.Url = "http://www.google.com";

        //Insert Text in search text box
        objFF.FindElement(OpenQA.Selenium.By.XPath("//input[contains(@id,'gbqfq')]")).SendKeys("ASP.NET");

        //Click on Search Button
        objFF.FindElement(OpenQA.Selenium.By.XPath("//button[@id='gbqfb']")).Click();

    }
}
Output :

(To view original size image , click on image)
Prerequisite 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.
Selenium C# : Insert text in website textbox with selenium C# webdirver

Full Video : 



Tuesday, 30 September 2014

Click Here to Download InsertTextInTextBox.zip

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] :
 
Selenium C# : Insert text in website textbox with selenium C# webdirver
(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 : 



Monday, 22 September 2014

There are various way to local element on web browser. We can use located element in selenium script to do automate things.
There are various locator types :
  • C# Locator
  • Java Locator
  • XPath Locator
  • Ruby Locator

We can Locate element by various way like by ID, Type, Name, CSS Class, etc..

Here are examples of locator strings which are useful in C# code to get value or perform any action on that element :

  • driver.FindElement(By.XPath("//input[@id='gbqfq']"));
  • driver.FindElement(By.XPath("//input[@name='q']"));
  • driver.FindElement(By.XPath("//input[@role='combobox']"));
  • driver.FindElement(By.XPath("//input[contains(@id,'gbqfq')]"));

Now to locate an element first you need to download and install FireFox Element Locator Add-on.

Selenium Tool : Download and Install FireFox Element Locator Add-on.

Tuesday, 16 September 2014

Click Here to Download OpenWebsiteInBrowserUsingSeleniumWebDriver.zip

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.

You can easily open any URL in browser automatically with selenium C# WebDriver. This is first and basic step of any WebSite testing and make to do automate WebSite running.

For this we are using 'Navigate' method and 'URL' property of WebDriver Browser class object.

Here you are learning open WebSite or URL with selenium C# WebDriver.

First, you need to create object of any browser in which you need to open WebSite or URL. You can create object of FireFox, Internet Explorer, Chrome, etc.

After creating object, you need call 'Navigate' method and then set WebSite URL which you need to open into 'URL' property.

Here is example for this.
In this example we are opening 'http://www.google.com' WebSite in FireFox web browser using selenium C# WebDriver.

Friday, 12 September 2014

Wednesday, 10 September 2014

Click Here to OpenChromeBrowserUsingSeleniumWebDriverTool.zip

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.

We can also open Chrome Browser programmatically using selenium C# 'WebDriver' API with ASP.Net C#.

In previous article we learned How to Open Internet Explorer and Firefox Browser using selenium 'WebDriver'.

For opening or launching Chrome is different from Open 'FF'. In that we need one extra EXE file named 'chromedriver.exe' file.

If you Do not have 'chromedriver.exe' file file at that time Code gives us an error like :
An exception of type 'OpenQA.Selenium.DriverServiceNotFoundException' occurred in WebDriver.dll but was not handled in user code.

Additional information: The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html.

Here are steps to learn How to Open Chrome Browser.

Friday, 5 September 2014

Click Here to Download OpenInternetExplorerWithSeleniumWebDriverTool.zip

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.


We can also open Internet Explorer Browser programmatically using selenium 'WebDriver' API with ASP.Net C#.

In previous article we learned How to Open Firefox Browser using selenium 'WebDriver'.

For opening or launching Internet Explorer (IE) is different from Open FireFox. In that we need one extra EXE file named 'IEDriverServer.exe' file and also set 'IE' Options object to give Startup URL.

If you Do not have 'IEDriverServer.exe' file file at that time Code gives us an error like :
The IEDriverServer.exe file does not exist in the current directory or in a directory on the PATH environment variable.

But basically it is very simple.

Here are steps to learn How to Open IE Browser :