Wednesday, 25 October 2017

Launch Microsoft Edge Browser in Selenium 3


Edge Browser in Brief:  Edge Browser is coming as an inbuilt browser with Microsoft Windows 10 Operating System. Prior to this, Microsoft was providing Internet Explorer Browser up to windows 7. Internet Explorer was not in competition with other browsers like Google Chrome, Mozilla Firefox etc. These browsers were very flexible, fast; good look and feel and also they are supporting lots of add-ons, which make user life very easy while working. Because of this growing competition Microsoft also decided to move on something, which will be rich in features and at the same time very easy to use. So they decided to come up with Microsoft Edge browser. This Edge browser is comparatively good looking and fast compare to Internet Explorer.
Since there is a rise in demand to automate a web application on different platforms and in different browsers Microsoft Edge browser is becoming very popular. To perform these cross-browser automation testing we need the following software. This software would help to launch the application in Microsoft Edge Browser and to perform various automation activities on the web application based on the requirements.
1.    Software Required: 
a)     Sharp Develop 5.1.0.5216
b)     C# Selenium Web Driver Client (3.6.0)
c)     Microsoft Web Driver
d)     Microsoft Edge Browser with Windows 10 operating system

2.    Configure Selenium in Sharp Develop IDE:
a) Follow the link and download Sharp Develop IDE http://filehippo.com/download_sharpdevelop/
    

  b) Go to the download location and double-click on Sharp Develop setup.exe file and click Next.

 c) Accept the License Agreement and keep on clicking Next until installation gets finished.


 d) Once the Installation gets over then launch the IDE. Click on New Solution and try to create the project.


  e) Select category as Windows Application and then select Console Application. Enter Name and Location where the project will get created and then click on Create.

 f) Once the project got created, the screen will be populated with some code as shown below.

g) In Sharp Develop IDE go to Project-> Manage Packages and enter Selenium in the search box and hit Enter. 
h) Select all the marked packages as shown in the image and add them to your project. 
i) Once again go to Project->Manage Packages and enter Microsoft Driver and Search. Add the selected package to the project as shown in the image.

j) Type following codes and save it.
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using System;
using System.Linq;

namespace SeleniumBasics
{
    class Programs
    {
            
       static void Main(string[] args)
       {
              // Instantiating WebDriver
              IWebDriver driver = new EdgeDriver();
      
           //MAXIMIZE THE BROWSER
           driver.Manage().Window.Maximize();

           //Enter the URL
           driver.Navigate().GoToUrl("https://www.google.co.in/");
    
           //Refresh the browser
           driver.Navigate().Refresh();
    
           //Wait for few seconds
           Thread.Sleep(10);
    
           //Close the browser
           driver.Quit();

       }

    }
}
k) Now you are ready to launch Microsoft Edge Browser. Click on Run button and it should launch Edge browser with google homepage.
I hope you would find this article simple and helpful if you are a beginner in C# automation. I also hope that this article would have helped you to do all the required setup to kick start with Selenium first script i.e. launching the browser this tutorial. In my next article, I will discuss how to add Selenium without using NuGet Package Manager. I will be coming with my new article very soon. Till then bye.
I would appreciate your comments. You can contact me anytime through email at jharakesh1991@gmail.com.

No comments:

Post a Comment

Appium Chapter-3: Understanding the Desired Capabilities

  Desired Capabilities help us to configure the Appium server and provide the criteria which we wish to use for running our automation scrip...