Class: BasePage

PFT. BasePage

PFT.BasePage - Represents a base object to extend from for UI testing. Ex:

function HomePage(page, url) {
  PFT.BasePage.call(this, page, url);
  this.HEADERLINK_CSS = '.header';
  this.registerKeyElement(this.HEADERLINK_CSS);
}
HomePage.prototype = Object.create(PFT.BasePage.prototype);
HomePage.prototype.constructor = HomePage;

new BasePage(page, baseUrl)

a base object to be used for navigating and validating a site
Parameters:
Name Type Argument Default Description
page PhantomJs.Webpage.Page <optional>
PFT.createPage() an existing Page object to be used by this class
baseUrl string <optional>
"" a URI root that can form the base for all extending classes
Source:

Methods

checkValidity()

function will ensure that each of the key elements are present on the page by looping through all selectors passed to PFT.BasePage.registerKeyElement and passing a boolean of 'true' if all exist otherwise 'false' and an error message
Source:

click(selector)

function will issue a PhantomJs click event on the specified selector
Parameters:
Name Type Description
selector string the CSS selector to use in identifying which element to click
Source:

eval(script, arguments)

function will evaluate the passed in javascript function within the page. Any arguments passed in after the function will be passed as arguments to the function
Parameters:
Name Type Description
script function the javascript function to be evaluated on the page
arguments Object an object to be passed to the function when executed
Source:

exists(selector)

function verifies that the passed in selector exists on the page
Parameters:
Name Type Description
selector string the CSS selector used to identify the element
Source:

extend(module)

function provides a MixIn ability for the PFT.BasePage and any subclasses which can be useful in splitting out sections of page functionality into separate modules such as those used to describe header, footer and body interactions within a page
Parameters:
Name Type Description
module Object the javascript Object to be mixed in to this page
Source:

getText(selector)

function will return the text content of the specified element.
Parameters:
Name Type Description
selector string the CSS selector to use in identifying which element to return the text content from within. The returned text will be from the specified element and any child elements and will not include HTML
Source:

open(urlParams, callback)

function will navigate to the 'baseUrl' specified on object creation
Parameters:
Name Type Argument Default Description
urlParams string <optional>
"" a string of URL Encoded values to be appended to the 'baseUrl'
callback function the function to execute after the page is loaded. on success the callback will be passed a boolean of 'true' otherwise 'false' and an error message will be passed to the callback
Source:

registerKeyElement()

function allows for registering key selectors that must be present on the page. this can then be verified through the PFT.BasePage.checkValidity function
Source:

renderPage(name)

function will pass the current 'PhantomJs.Webpage.Page' to PFT.renderPage
Parameters:
Name Type Argument Default Description
name string <optional>
page.url an optional name to use for the image name
Source:

sendKeys(selector, value, callback, keyDelay)

function will place focus on the specified selector and then send a keydown followed by a keyup event for each character of the passed in value string. when completed the callback will be called with a value of true
Parameters:
Name Type Argument Default Description
selector string the CSS selector to use in identifying which element will have focus for the keys
value string the text string to be typed
callback function the callback function to be called after all characters have been sent
keyDelay Integer <optional>
25 the delay in milliseconds between each keypress
Source:

waitFor(selector, callback, maxMsWait)

function will verify the presence of the passed in selector by polling the page up to the 'maxMsWait' and will pass a boolean 'true' to the callback if found otherwise 'false' and an error message
Parameters:
Name Type Argument Default Description
selector string the CSS selector used to identify the element on the page
callback function a function to be called when the element is found or when the maximum wait time has passed
maxMsWait Integer <optional>
PFT.DEFAULT_TIMEOUT the maximum number of milliseconds to wait while attempting to locate the passed in selector
Source: