Progressing towards Innovation...


Web Automation (Browser Control)

June 20, 2014by GLBADMIN2

Hi, I am Amit Soni, a Senior .NET Developer at Globussoft with 4+ years of experience on and frameworks. I have put together my ideas on how to do a simple web automation here.

Web Technologies and Automation

Web technology is a term increasingly used in the same wavelength as automation.

As always with newer technologies or fields of use, a certain confusion remains about terminology in the early days. The development of computer software is not an easy task. Besides development of the concept that lies behind the software, the software engineers also need to devise means and methodologies in order to guarantee complete application of the concept by the software that is being developed. Moreover, it is important for engineers to ensure that the developed software is devoid of any kind of glitches and bugs before they are released commercially. This is exactly where the need for automated software comes into existence.

Applications and Advantages of Control Technology

Many Technologies have been developed for Web Automation. Here I am introducing two basic web automation components which we use for Web Automation:

  1. Web browser control
  2. Watin web browser control

Both are based on internet explorer.

Web browser control is a very interesting programming part of automation. I have worked on a number of web automation and web robots projects and used web browser control effectively. Web browser control provides a user interface which is same as manual work. Simple Socket program has many issues like running JavaScript, but web browser rules out these issues by itself. I would now demonstrate the web browser concept with some of the codes of my project.

The above image shows the page where we use web browser control. Web window redirects you to the site which you want to automate and then by using the Web browser control you can use handle Site’s controls like buttons and events.

For Redirect we use –


For Controls –

webHotmail.Document.GetElementById("iFirstName").SetAttribute("value", fName);
webHotmail.Document.GetElementById("iLastName").SetAttribute("value", lName);
webHotmail.Document.GetElementById("iBirthYear").SetAttribute("value", yy);
webHotmail.Document.GetElementById("iBirthMonth").SetAttribute("value", mm);

For Events –

webHotmail.Document.GetElementById("iSA").SetAttribute("value", petname);
if (gender == true)
    IHTMLElement h1 = (IHTMLElement)webHotmail.Document.GetElementById("iGenderMale").DomElement;;


Automated Web Testing Using WatiN

WatiN (what-in), stands for Web Application testing in .NET, is a very easy automated web application testing framework. WatiN is developed in C# for web testing with Internet Explorer and FireFox.

According to Scott Guthrie, this will give you exactly the experience that you’ll have when a customer hits the site, which ends up being a far more accurate assessment of the application quality.

We are using the same task type as web browser but code structure is different.

For example

using Microsoft.VisualStudio.TestTools.UnitTesting;
using WatiN.Core;
public class WatiNTest
    public void GoogleTest()
        bool hasText;
        using (IE ie = new IE())
            hasText = ie.ContainsText("Dixin");


Significant Advantages of Conducting Automated Software Testing

Easy to perform certain tests repeatedly: Most software testing tools allow testers to configure the tests once based on certain parameters. You can use the configuration to administer the test over and over without putting any extra effort.

Smooth running of loads of tests and cases: As the running and rerunning of test scripts manually needs a huge amount of time, it may prolong the project completion date. So many testers use testing tools to easily execute the test scripts till they are sure about the accuracy of test results.

Saves your time and resources: You can always save both time and resources by automating the testing process. As the test scripts can be reused to target several user interfaces, and the tests can be administered in less time, you can easily develop a quality application, while saving funds.

Make your software more reliable: Each testing tool further allows you to build a suite of test to cover all features and functionality of the application. The comprehensive testing can emulate user behavior accurately that will contribute toward boosting the efficiency, performance and reliability of the application.

Reusability of the test: A tester has options to choose from a variety of test automation tools. However, the prices of the testing tools will vary based on the expected features and functionality. These features make it easier for software testers to reuse a single test script to administer application testing.

Quick testing of cross-platform applications: Each successful application has to be compatible with major operating systems and devices. So most companies, nowadays, develop cross-platform software applications. If you are developing a web application, it must run on major web browsers like Internet Explorer, Firefox, Chrome and Opera.

Thank You! It’s a pleasure to share. You can share your ideas with me here too.