Namespace: PFT

PFT

Source:

Classes

BasePage

Namespaces

logger
tester

Members

<static> DEFAULT_TIMEOUT

property used as a default wait timeout in the 'PFT.tester' module
Properties:
Name Type Argument Default Description
PFT.DEFAULT_TIMEOUT number <optional>
60000 the number of milliseconds used by default for any waiting like PFT.BasePage.waitFor
Source:

<static> IGNORE_PAGE_ERRORS

Properties:
Name Type Argument Default Description
PFT.IGNORE_PAGE_ERRORS boolean <optional>
false by default all page errors (script errors on the page) will result in an error and halting of current processing. if set to true these will be ignored
Source:

<static> IMAGES_DIR

property defining the base directory used with 'PFT.renderPage' and 'PFT.BasePage.renderPage' calls
Properties:
Name Type Argument Default Description
PFT.IMAGES_DIR string <optional>
'./img/' the default directory where any images will be written
Source:

<static> POLLING_INTERVAL

property specifying the delay between retries when waiting for selectors to be displayed
Properties:
Name Type Argument Default Description
PFT.POLLING_INTERVAL number <optional>
1000 the number of milliseconds between retries used in any polling like PFT.BasePage.waitFor
Source:

Methods

<static> addHeader(page, name, value)

function will add a header to the passed in 'PhantomJs.Webpage.Page' object or overwrite an existing header with the passed in value
Parameters:
Name Type Description
page PhantomJs.Webpage.Page the Page object to set headers on
name string the name of the header such as "Accept-Language"
value string the value of the header such as "en-US"
Source:

<static> addHeaders(page, headers)

function will add headers to the passed in 'PhantomJs.Webpage.Page' object or overwrite them if they already exist
Parameters:
Name Type Description
page PhantomJs.Webpage.Page the Page object to set headers on
headers Object[] an array of Objects containing a name and value
headers[].name string the header key such as "Accept-Language"
headers[].value string = the header value such as "en-US"
Source:

<static> convertMsToHumanReadable(milliseconds) → {string}

function will convert a passed in millisecond value to a more human-readable output format of HHH hours MM minutes SS seconds mmm milliseconds
Parameters:
Name Type Description
milliseconds Integer the milliseconds to be converted
Source:
Returns:
a human-readable string representing the passed in value
Type
string

<static> createPage(viewport, headers) → {PhantomJs.Webpage.Page}

function will create a new page in PhantomJs with the passed in viewport dimensions or a default of 1024x800 and using the passed in headers. If called within a PFT.tester.test the returned page will also be set as the PFT.tester.current.page object
Parameters:
Name Type Argument Default Description
viewport Object <optional>
{width:1024,height:800} an object containing the 'width' and 'height' properties to use with the new page. Ex: { width: 1024, height: 768 }
headers Object[] <optional>
an array of objects containing a 'name' and 'value' property which will be set as headers for all requests using the returned page. Ex: [{ name: "Accept-Language", value: "en-US" }]
headers[].name string the header key such as "Accept-Language"
headers[].value string = the header value such as "en-US"
Source:
Returns:
a new page object
Type
PhantomJs.Webpage.Page

<static> debug()

convenience method for PFT.logger.log with a value of PFT.logger.DEBUG passed as the first parameter
Source:

<static> error()

convenience method for PFT.logger.log with a value of PFT.logger.ERROR passed as the first parameter and a boolean value of 'true' passed as the last parameter
Source:

<static> getCookieValue(cookieName) → {string}

function will return the value of the specified Cookie if it exists
Parameters:
Name Type Description
cookieName string the name of the Cookie to be retrieved
Source:
Returns:
the value of the specified Cookie or undefined if not found
Type
string

<static> guid() → {string}

function will generate a GUID or UUID complete with dashes between the sections
Source:
Returns:
a guid in the form of XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Type
string

<static> info()

convenience method for PFT.logger.log with a value of PFT.logger.INFO passed as the first parameter
Source:

<static> onPageConsoleMessage()

function hook allowing for "listening" to any console messages sent by the 'PhantomJs.Webpage.Page' objects
Source:

<static> renderPage(page, name)

function will create a JPG with a quality of 50% using either the passed in name or the passed in 'PhantomJs.Webpage.Page' url if no name is passed. The image will be written to the PFT.IMAGES_DIR directory with the name formatted to remove spaces and illegal characters
Parameters:
Name Type Argument Default Description
page PhantomJs.Webpage.Page the Page object to be rendered
name string <optional>
page.url a name to be used for the image
Source:

<static> resizeViewport(page, dimensions)

function will resize the passed in PhantomJs.Webpage.Page to the specified dimensions
Parameters:
Name Type Description
page PhantomJs.Webpage.Page the Page object to resize
dimensions Object an Object containing a width and height property set to values greater than 0
Source:

<static> trace()

convenience method for PFT.logger.log with a value of PFT.logger.TRACE passed as the first parameter
Source:

<static> warn()

convenience method for PFT.logger.log with a value of PFT.logger.WARN passed as the first parameter
Source: