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 :

Tuesday 2 September 2014

We can open FireFox Browser programmatically using selenium webdriver API with ASP.Net C#. Here you can Learn how to open Firefox browser using selenium webdriver with ASP.Net C#

STEP 1 : First you need to create empty 'Website' or in existing 'Website' or project you need to add selenium 'WebDriver' API DLL references.
You can visit this link to create new 'Website' and add selenium 'WebDriver'API DLL references.

Selenium Tool : Download selenium Webdriver for ASP.NET C#.
Selenium Tool : Configure selenium tool for asp.net C# website or project in Visual Studio.