Selenium Setup in Visual Studio

Selenium Setup in Visual Studio

This is a generalized guide for configuring Selenium on Windows.

  1. Create a directory named Selenium under C:\
  2. Copy the directory downloaded from http://docs.seleniumhq.org/download/ in this example I'm setting up the Java specific package.
  3. Within IE set all Security Zones to the same protection level
  4. Add wildcards for your internal domain as exceptions within trusted sites. IE: http://sub.internal.domain.com & https://sub.internal.domain.com (SSL Support)
  5. Download and Install Resharper from https://www.jetbrains.com/resharper/
  6. Set the following options in VS for the Resharper Plugin:
    Resharper > Options > Tools > Unit Testing > MsTest to use Parallel Test Run Config (Drop-down)
  7. As this point you should be able to successfully execute WebDriver tests locally from Within Visual Studio. If you don't wish to use Grid: “useGrid = false” within the properties file. If you wish to utilize the Grid continue with the steps below.
  8. Download and install the JDK suite from: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. Install everything under C:\Selenium, this should create a jdk directory. You can test the successful installation of jdk by opening CMD Prompt and typing java. This should populate commands.
  9. Start hub/nodes by double clicking the appropriate .bat scripts located within C:\Selenium. If you don't have the scripts listed you'll need to download the WebDriver for each browser you wish to test in:
    https://sites.google.com/a/chromium.org/chromedriver/downloads
    https://github.com/mozilla/geckodriver/releases
    https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
    Here I'll give a script example for each:
    run_chrome_node.bat
    java -jar selenium-server-standalone-2.44.0.jar -role node  -hub http://localhost:4444/grid/register -browser "browserName=chrome,maxInstances=3,platform=WINDOWS" -port 5557 -Dwebdriver.chrome.driver="C:\selenium\chromedriver.exe"
    run_firefox_node.bat
    java -jar selenium-server-standalone-2.44.0.jar -role node  -hub http://localhost:4444/grid/register -browser "browserName=firefox,maxInstances=3,platform=WINDOWS" -port 5558
    run_ie_node.bat
    java -jar selenium-server-standalone-2.44.0.jar -role node  -hub http://localhost:4444/grid/register -browser "browserName=internet explorer,maxInstances=1,platform=WINDOWS" -port 5556 -Dwebdriver.ie.driver="C:\selenium\IEDriverServer.exe"
    Each of these scripts above should be in your selenium directory with the appropriate executable.
  10. Test Selenium by opening up the Selenium Test VS project under C:\selenium
  11. Browse to UnitTest1.cs and right-click UnitTest1 under TestClass. Select Run Tests. This should automatically open firefox so you can be sure selenium was successfully installed.

If you still have issues at this step Right-Click References under ClassLibrary1 in VS and select Manage NuGet Packages... Search on the top right of your screen for Selenium and install both the Selenium WebDriver and Selenium WebDriver Support Classes packages.

Try to run the test again and you should be set to start testing your application!