Skip to content

Golem.WebDriver, Getting Started

RBurrows-ProtoTest edited this page Feb 4, 2014 · 29 revisions

===== ###Guide Navigation

  1. Overview
  2. Test Creation
  3. Test Configuration
  4. Test Execution

=====

###Selenium WebDriver C# Framework

Selenium WebDriver is collection of language specific bindings used to drive browser actions natively the way a real user would. Combined with the Golem’s Core functionality, you now have a powerful tool to create and execute robust, browser-based test automation scripts.

By default, the framework will automatically launch Firefox on your local browser before each test, and instantiates a WebDriver instance. The Config class or an App.Config file can be used to control which browsers are used during testing.

Golem includes a variety of features that can globally enabled for every test. For example, having each WebDriver command written to the test log.

=====

###Creating a Test

  • Create a new Class Library File > New > Project > Class Library.
  • Right click on references > Manage NuGet Packages
  • Add Package “ProtoTest.Golem”.
  • WebDriver is available via "driver" property.
  • Paste the following code into your class file, save the project/solution, and build:
using MbUnit.Framework;
using ProtoTest.Golem.Tests.PageObjects.Google;
using ProtoTest.Golem.WebDriver;

namespace ProtoTest.Golem.Tests
{
    class Test : WebDriverTestBase
    {
        [Test]
        public void TestGoogle()
        {
            OpenPage<GoogleHomePage>("http://www.google.com/").SearchFor("Selenium").VerifyResult("Web Browser Automation");
        }
	}
}

=====

Configuring Tests

Through an App.Config:

  • Add an "Application Configuration File".
  • Edit the App.config -> Set browser using key “Browser1” value=”Firefox”
<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="Browser1" value="Firefox"/>
   </appSettings>
</configuration>
  • Execute Test - Should open Firefox instead of Chrome.
  • Supports Firefox, Chrome, IE, Safari, HtmlUnit, and Android (remote only)

Through code:

[FixtureInitializer]
        public void init()
        {
            Config.Settings.httpProxy.startProxy = false;
            Config.Settings.httpProxy.useProxy = false;
        }

=====

Executing a Test

From Within Visual Studio:

  • TestDriven.net plugin is required
  • Right Click on Test > Run Test (Should open browser and close it)
  • Right Click on Class or project to run all tests within.

From Gallio Icarus:

  • Open Gallio Icarus
  • Click "Add" and navigate to our ProjectName.dll file located in the /bin/release or /bin/debug/ directory.
  • Select tests to execute.
  • Click Run.

####Executing on a Remote Computer:

  • Modify App Config, set host to IP or Hostname of remote computer
<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="Browser1" value="Chrome"/>
    <add key="RunOnRemoteHost" value="True"/>
    <add key="HostIp" value="10.10.1.151"/>
   </appSettings>
</configuration>

Clone this wiki locally