Friday, 5 September 2014

Selenium C# : How to Open Internet Explorer Browser using selenium webdriver with ASP.Net C#

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 :


STEP 1 : First create new 'WebSite' after creating new 'WebSite' add new page. On this previous article your learn this.

STEP 2 : Now, you need special Executable (EXE) file named "IEDriverServer.exe". You can download this file from this URL :
http://selenium-release.storage.googleapis.com/index.html. You can choose latest version folder on this link. Or you can also get this file from our project zip file, In our project we have both 32 and 64 bit zip file. You can get that file from zip file.

STEP 3 : After downloading file, Add new folder in your website or project named it 'EXEFiles' and copy your downloaded file 'IEDriverServer.exe' in this folder.

STEP 4 :  Open your new page code file like 'Default.aspx.cs' file. Import selenium 'namespaces' and write following code on 'Open Internet Explorer Browser' button click event.

Code File :
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)
    {

    }
    protected void btnOpenIEBrowser_Click(object sender, EventArgs e)
    {
        string STR_IE_DRIVER = Server.MapPath("EXEFiles"); //Set Path for EXE file

        var objIEOptions = new OpenQA.Selenium.IE.InternetExplorerOptions() // Set Options
        {
            InitialBrowserUrl = "www.google.com",
            IntroduceInstabilityByIgnoringProtectedModeSettings = true
        };

        //Create object for open IE
        OpenQA.Selenium.IE.InternetExplorerDriver objFF = new OpenQA.Selenium.IE.InternetExplorerDriver(STR_IE_DRIVER, objIEOptions);
    }
}

Explanation : In this code you can see that First we set path of 'IEDriverServer.exe' file, in which folder we save this file. After that, we create object of 'InternetExplorerOptions' class and set properties like 'InitialBrowserUrl' and 'IntroduceInstabilityByIgnoringProtectedModeSettings'.

This 'InitialBrowserUrl'  property use for By default when IE open this URL is open in IE. After that, we create object of 'InternetExplorerDriver' class to open IE. You can see that in constructor of 'InternetExplorerDriver' class we supply 'IE_DRIVER' Path and 'IE OPTION' object.

STEP 5 : Run the website. After Default page is appeared in browser, this website may run in any browser. You click on 'Open Internet Explorer Browser' button. It will Open Internet Explorer Successfully.

[Image : Run Website and open Page] :

Selenium C# : How to Open Internet Explorer Browser using selenium webdriver with ASP.Net C#
(To view original size image , click on image)

[Image : Internet Explorer Opened] :

Selenium C# : How to Open Internet Explorer Browser using selenium webdriver with ASP.Net C#
(To view original size image , click on image)


Full Video : 



17 comments:

  1. really well said about How to Open Internet Explorer Browser using selenium webdriver with ASP.Net C# keep share interesting article on selenium

    Selenium Training Institute in Chennai

    ReplyDelete
  2. Great article!!!!!This is very important information for us.I like all content and information.I have read it.You know more about this please visit again. Best Hadoop Training | Hadoop Online Training

    ReplyDelete
  3. Nice information about test automation tools my sincere thanks for sharing post Please continue to share this post..


    Weblogic Server 12cR2 Training

    ReplyDelete
  4. Thanks you for nice article.
    if you want to know the technologies updates,visit below site.
    Dot Net Tutorial for Beginners with Examples

    ReplyDelete

  5. Very Helpful Post And Explained Very Clearly About All the things.Very Helpful. Coming To Our Self We Provide Food Service Parts Through Out US At Very Affordable Prices And Also We Offer Same Day Shipping In US.We Offer Only Genuine Products.Really Thanks For Posting.

    ReplyDelete
  6. Thankful for the Informative Post The Best article, Bala Guntipalli

    ReplyDelete
  7. This Blog is very helpful and useful,came to know that i should be strong in my basics and this blog helps me to improve it,Chicago Immediate Care Services Provided by Us.Thanks For Posting.I Am refereed by my friend to this blog and i also want to refer my other friends to this blog.Really Thanks for posting such an informative post and thanks for sharing such knowledgeable posts.

    ReplyDelete
  8. This Blog Provides Very Useful and great Information. United States Medical Licensing Examination Thanks for sharing.

    ReplyDelete
  9. I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about tutorials for beginners with reference of your blog. 
    Devops training in velachry
    Devops training in OMR
    Deops training in annanagar
    Devops training in chennai
    Devops training in marathahalli
    Devops training in rajajinagar
    Devops training in BTM Layout


    ReplyDelete
  10. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
    Data science training in velachery
    Data science training in kalyan nagar
    Data Science training in OMR
    Data Science training in anna nagar
    Data Science training in chennai
    Data Science training in marathahalli
    Data Science training in BTM layout
    Data Science training in rajaji nagar

    ReplyDelete
  11. Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…

    java training in annanagar | java training in chennai

    java training in marathahalli | java training in btm layout

    java training in rajaji nagar | java training in jayanagar

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete


  13. Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision.

    angularjs-Training in annanagar

    angularjs Training in chennai

    angularjs Training in chennai

    angularjs Training in bangalore

    ReplyDelete
  14. myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance

    ReplyDelete
  15. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
    python training in OMR
    python training in tambaram
    python training in annanagar

    ReplyDelete
  16. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    rpa training in velachery| rpa training in tambaram |rpa training in sholinganallur | rpa training in annanagar| rpa training in kalyannagar

    ReplyDelete