Golem.WebDriver, Technical Details - ProtoTest/ProtoTest.Golem GitHub Wiki

===== ###Guide Navigation

  1. Features
  2. Configurable Options
  3. Building a new Page Object

=====

###Features #####Golem.Core

  • Fully configurable programmatically or with an App.Config. Config class reads the App.config and stores all values as properties. Each value should have a default defined.
    
  • Test class should inherit TestBaseClass, and each test function should be marked with the [Test] attribute.
    
  • Built on the Page Object Design Pattern. Page Objects should inherit BasePageObject.
    
  • Page Objects need to define a WaitForElements() function. This is called automaticly alled when the PO is instantiated. You should put waits or validations in here to wait or validate that a page object is fully loaded and ready to be used.
    
  • Page Objects don't need a constructor. The base constructor instantiates everything, and the driver object is stored statically in the TestBaseClass.
    

#####MbUnit Integration

  • You can use MbUnit.Framework.Assert to make assertions. These will stop the test on failure.
    
  • Supports data driven testing through MbUnit attributes.
    

#####WebDriver Integration

  • Selenium GRID/SauceLabs supported.
    
  • Created a variety of Verifications in the WebDriver API. These will not stop the test if they fail.
    
  • Optional Element class wraps and hides WebDriver API.
    
  • Using EventDrivenWebDriver to log commands.
    
  • Multi-threaded support (Parallel test execution).
    
  • WebDriver driver is instantiated automatically for each test, and stored in a static IDictionary in the TestBaseClass. This is for multi-threaded support. Each thread automatically knows which driver belongs to it. Access it in any test or page object like "driver.FindElement".
    

=====

Configurable Options

  • Multi Threaded Execution. Mark test with [Parallelizable] attribute. Set number of threads with "DegreeOfParallelism", "1"
    
  • Automatically Launch Browser - LaunchBrowser", "True"
    
  • Specify up to five browsers - "Browser1" value="Firefox"
    
  • Add a delay between commands - "CommandDelayMs" value="0"
    
  • Run on local or remote computer - "RunOnRemoteHost" value="false", "HostIp" value="localhost"
    
  • Capture screenshot on error - "ScreenshotOnError" value="True"
    
  • Capture page html source on error - "HtmlOnError" value="True"
    
  • Capture screen video recording on error - "VideoRecordingOnError", "True"
    
  • Write all webdriver commands to the log - "CommandLogging" value="True"
    
  • Write all page object functions to the log - "ActionLogging" value="True"
    
  • Launch a proxy to capture http traffic - "StartFiddlerProxy" value="True", "ProxyPort" value="8876"
    
  • Appium support - "LaunchApp", "False" - "AppPath", "" - "AppPackage", "" - "AppActivity", "" - "AppOs", "Android"
    
  • Configurable Test timeout - "TestTimeoutMin","5"
    
  • Configurable element Timeout - "ElementTimeoutSec","20"
    
  • Configurable environment Url - "EnvironmentUrl",""
    
  • Automatically check spelling on each page
    

=====

###Building a new Page Object

  • Look in the Tests/PageObjects directory in the Golem repository for examples
  • Page Objects Inherit BasePage
  • Instances of Element represent elements in the web page under test
  • The Element API provides convenient methods for locating elements
  • WebDriver API available through 'driver' property;
  • WaitForElements method is called when page object is instantiated. Use it to wait for dynamic elements.
using OpenQA.Selenium;
using ProtoTest.Golem.WebDriver;

namespace ProtoTest.Golem.Tests.PageObjects.Google
{
    public class GoogleHomePage : BasePageObject
    {
        Element searchField = new Element("SearchField", By.Name("q"));
        Element googleLogo = new Element("GoogleLogo", By.Id("hplogo"));
        Element searchButton = new Element("SearchButton", By.Name("btnK"));
        Element feelingLuckyButton = new Element("ImFeelingLuckyButton", By.Name("btnI"));
        Element signInButton = new Element("SignInButon", By.LinkText("Sign in"));

        public GoogleResultsPage SearchFor(string text)
        {
            searchField.Text = text;
            searchField.Submit();
            return new GoogleResultsPage();
        }

        public override void WaitForElements()
        {
            searchField.Verify().Present();
            googleLogo.Verify().Present();
            searchButton.Verify().Present();
            feelingLuckyButton.Verify().Present();
            signInButton.Verify().Present();
        }
    }
}