Wednesday, 10 September 2014

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

Click Here to

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

Here are steps to learn How to Open Chrome Browser.

STEP 1 : First create new 'WebSite', after creating new 'WebSite' add selenium webdriver dll and also add new page. On this previous article your learn this.

STEP 2 : Now, you need special Executable (EXE) file named "chromedriver.exe". You can download this file from this URL : You can choose latest version folder on this link. Or you can also get this file from our project by downloading project source code.

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

STEP 4 : Open your new page code file. Import selenium 'namespaces' and write following code on 'Open Chrome 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 btnOpenChrome_Click(object sender, EventArgs e)
        string STR_DRIVER_PATH = Server.MapPath("EXEFiles");
        OpenQA.Selenium.Chrome.ChromeDriver objCD = new OpenQA.Selenium.Chrome.ChromeDriver(STR_DRIVER_PATH);

Explanation : In this code you can see that First we set path of 'chromedriver.exe' file, in which folder we save this file. After that, we create object of 'ChromeDriver' class to open Chrome browser, which exist in 'OpenQA.Selenium.Chrome' namespace. You can see that in constructor of 'ChromeDriver' class we supply 'CHROME_DRIVER' Path.

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

[Image : Run Website and open Page] :

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

[Image : Chrome Browser Opened] :

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

Full Video : 


  1. Hello,
    Is it possible to run this once published on server?
    I tried but wihout any luck. It just spins whn press the button.
    Thank you!

  2. This is really informative article for new learner. Author explained all the things very nicely in this article and everyone can easily understand it. Really appreciated

    Now buffalo website design service is available from Crystal Tech Solution in a professional way.