Selenium has 2 version 1.0 and 2.0. During this article, I just mention about Selenium 2.0. Basically, it is used for testing web application by automation program written by Java, C#, Python... To do that, the test application (created by a tester) will control the browser which the web application (need to be tested) runs on via Selenium webdriver. The browser can be Chrome, FireFox, Internet Explorer... Each browser has a corresponding webdriver to control it.
In this post, I want to introduce Selenium with C#. To start, you must install MS Visual Studio - MSSV (2015 community is preferred) and download Selenium client & webdriver. Below are steps to create
1. Open MSVS and create new C# Windows project, see the following picture for example:
2. Add references for Selenium client & webdriver. There are 2 ways.
2.1 Use Add Reference menu:
3. Code your test application. Below is simple code for opening Chrome with google.com website
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace SeleniumTutorial
{
class Program
{
static void Main(string[] args)
{
IWebDriver wd = new ChromeDriver(@"E:\working\abc\SeleniumTutorial");
wd.Url = "http://google.com";
}
}
}
In which, @"E:\working\abc\SeleniumTutorial" is the folder containing Chrome Webdriver (chromedriver.exe).
Yeah! We already knew how to start a C# project with Selenium. I think that's enough for Part 1. In Part 2, we will learn more details how to code a test application with some real test scenarios, for example how to login Facebook automatically.
Any comment is welcome. Have a great day!
I really admired your post, such great and useful information that you have mentioned here.
ReplyDeleteAutomation Training in Chennai
Automation Anywhere Training in Chennai
Automation Anywhere Training Institutes in Chennai
RPA Classes in Chennai
Blue Prism Training Chennai
Blue Prism Training Institute in Chennai
RPA Training in Chennai
UiPath Training in Chennai
Blue Prism Training in Velachery