Jeremy Bellows - Marquee Documentation

Marquee Documentation

-


Marquee

Marquee is an open source, Selenium based, UI Automation library. Inspired by lefthandedgoat’s excellent, C# compatible library canopy.

Marquee Test Suite

The marquee test suite is broken down into the following components.

  • open Marquee and TestManager dependencies
  • specify the maximum amount of browsers that are able to run concurrently
  • specify the function for reporting test results
  • create the test manager
  • register tests
  • tell the test manager to run the tests
  • end the test manager
  • exit the program

Dependencies

The Marquee module loads the crucial BrowserType for specifying the Browser

open Marquee
//The TestManager module loads test registration and concurrent execution types
//As well as the TestResultsFunction for handling test results
open TestManager

Configurations

Specify the AmountOfBrowsers configuration for concurrent execution
MaximumBrowsersPossible is based on total registered tests
other option is the following IWantThisManyBrowsers 3

let amountOfBrowsers = MaximumBrowsersPossible
//Also possible is the IWantThisManyBrowsers(int) option
let specificAmountOfBrowsers = IWantThisManyBrowsers 10

Browser

Currently supported browsers are

  • Chrome
  • Firefox
  • PhantomJS
let chromeBrowser = Chrome(CurrentDirectory)
let firefoxBrowser = SpecificDirectory __SOURCE_DIRECTORY__ |> Firefox
let phantomJsBrowser = CurrentDirectory |> PhantomJs

TestResultsFunction

The TestResultsFunction is used for configuring how test results are reported or saved

ConsoleReporter is a module provided by Marquee for reporting via the console

let testResultsFunction = ConsoleReporter.resultsFunction

TestManager

A TestManager handles test registration, test execution, and test results

We can start a testManager instance by calling TestManager.Create

TestManager.Create has the function signature
TestManagerConfiguration -> TestManager

let testManagerConfiguration : TestManagerConfiguration =
  {
    BrowserType = firefoxBrowser
    InfoFunction = ConsoleReporter.infoFunction
    TestResultsFunction = testResultsFunction
    AmountOfBrowsers = amountOfBrowsers
    AssertionTimeout = 5000
    ElementTimeout = 5000
  }
let testManager = testManagerConfiguration |> TestManager.Create

Optional Test Registration Operator

Define an operator for test registration

let (--) testDescription testFunc = testManager.Register testDescription testFunc

Test Registration

//Describe what the test is testing for and start the test function
"Button should click" -- fun browser ->
//Use the supplied browser to navigate to a specific url
  browser.Url "http://lefthandedgoat.github.io/canopy/testpages/"
//Assert that elements gathered using the css selector have the test "button not clicked"
  "#button_clicked" |> browser.ElementTextEquals "button not clicked"
//Click the elements gathered with the css selector #button
  browser.Click "#button"
//Assert that elements gathered using the css selector have the test "button clicked"
  "#button_clicked" |> browser.ElementTextEquals "button clicked"
//Assert that an element that matches the css selector #welcome is displayed
  browser.Displayed "#welcome"
//Assert that elements gathered using the css selector have the text "Welcome"
  "#welcome" |> browser.ElementTextEquals "Welcome"

alternative is to register tests using the following

testManager.Register "If some action occurs something specific should happen" fun browser ->
  browser.Url "www.eff.org"

Executing Tests

Start concurrent execution of registered tests

testManager.RunTests ()
//Report the results via the TestResultsFunction and get exit code from test session
let exitCode = testManager.ReportResults ()
//End the Manager instance
testManager.EndManager ()
//exit the program and return the exitCode from the test results
exit exitCode

Marquee Module

Types

The following sections describe the various types that Marquee uses

BrowserDirectoryOption

The BrowserDirectoryOption type is used for specifying the location of a web driver
To specify a specific location use the following syntax

BrowserDirectoryOption.SpecificDirectory "C:\webdrivers"

Or use the CurrentDirectory option

BrowserDirectoryOption.CurrentDirectory

BrowserType

BrowserType is used to define what browser the tests should use
Current Options are Chrome, Firefox, or PhantomJs
The BrowserType takes a BrowserDirectoryOption
Use the syntax

BrowserType.Chrome(CurrentDirectory)

or

BrowserType.Chrome(SpecificDirectory "C:\webdrivers")

BrowserConfiguration

The BrowserConfiguration type is a record that is passed to the Browser.Create function
For example

let browserConfiguration : BrowserConfiguration =
  {
    BrowserType = Chrome(CurrentDirectory)
    ElementTimeout = 5000
    AssertionTimeout = 5000
  }

BrowserType

BrowserType in the BrowserConfiguration record sets what browser the webdriver should launch

ElementTimeout

The ElementTimeout in the BrowserConfiguration record is an integer that sets the amount of milliseconds that a Marquee action takes before giving up.
This is useful when dealing with web content that is slow to update on the page

AssertionTimeout

The AssertionTimeout in the BrowserConfiguration record is an integer that sets the amount of milliseconds that a Marquee assertion takes before giving upd.
This is useful when dealing with web content that is slow to update on the page

Browser

Browser is the main record type for Browser manipulation in Marquee

Create

The Create function is used to create a live browser instance
For example

let browserConfiguration : BrowserConfiguration =
  {
    BrowserType = Chrome(CurrentDirectory)
    ElementTimeout = 5000
    AssertionTimeout = 5000
  }
browserConfiguration |> Browser.Create

Url

The Url function navigates the browser to the supplied url string
For example

browser.Url "http://www.github.com"

Quit

Quit is used to end the live browser instance
When using the built in TestManager this function isn’t necessary to call

browser.Quit()

FindElements

FindElements searches the current page the browser is on for web elements that match the provided CSS selector
For example

let cssSelector = ".some_class"
browser.FindElements cssSelector

Click

The Click function clicks all web elements that match the provided CSS Selector
For example

let cssSelector = ".some_button"
browser.Click cssSelector

Displayed

The Displayed function asserts that some element that matches the provided CSS selector is displayed
For example

let cssSelector = ".welcome_text"
browser.Displayed cssSelector

ElementTextEquals

The ElementTextEquals function asserts that all elements that match the provided cssSelector contains some text
For example

let cssSelector = ".welcome_message"
"Welcome to the website!" |> browser.ElementTextEquals cssSelector

ClearInput

The ClearInput function clears the text input of all web elements that match the provided CSS selector
For example

let cssSelector = ".username"
browser.ClearInput cssSelector

SetInput

The SetInput function sets the input text of all web elements that match the provided CSS selector

let cssSelector = ".username"
"JohnDoe" |> browser.SetInput cssSelector

TestExistsInElements

The TestExistsInElements function asserts that at least one web element that matches the provided CSS selector also matches the supplied text
This is different than ElementTextEquals because ElementTextEquals asserts that all elements match the provided text
ElementTextEquals is used when the CSS selector is specific to one type of web element
TestExistsInElements is used when the CSS selector is general and may gather multiple web elements

For example

let cssSelector = "div"
"Welcome to the website!" |> browser.TextExistsInElements cssSelector

CheckElements

The CheckElements function performs the check action on a checkbox web element
For example

let cssSelector = ".some_checkbox"
browser.CheckElements cssSelector

UnCheckElements

The UnCheckElements function performs the uncheck action on a checkbox web element
For example

let cssSelector = ".some_checkbox"
browser.UnCheckElements cssSelector

AreElementsChecked

The AreElementsChecked function asserts that all web elements gathered by the provided CSS selector are checked
For example

let cssSelector = ".some_checkbox"
browser.AreElementsChecked cssSelector

AreElementsUnChecked

The AreElementsUnChecked function asserts that all web elements gathered by the provided CSS selector are unchecked
For example

let cssSelector = ".some_checkbox"
browser.AreElementsUnChecked cssSelector

SetSelectOption

The SetSelectOption function sets a select web element to the specified option

For example
Say we wanted to select Option One for the following html snippet

let cssSelector = ".some_select"
cssSelector |> browser.SetSelectOption "Option One"

IsOptionSelected

The IsOptionSelected function asserts that the specified option in a select web element is selected

let cssSelector = ".some_select"
cssSelector |> browser.SetSelectOption "Option One"
cssSelector |> browser.IsOptionSelected "Option One"

AlertTextEquals

The AlertTextEquals function asserts that a browser alert has the supplied text

browser.AlertTextEquals "Warning!"

AcceptAlert

The AcceptAlert function initiates the accept action on a browser alert

browser.AcceptAlert ()

DismissAlert

The DismissAlert function initiates the dismiss action on a browser alert

browser.DismissAlert ()

Contributing and copyright

code repository
issues
readme
license