sgapps.io-testing-platform v1.1.17
๐ SGApps.IO Testing Platform
Easy way to build testing scenarios
๐ SGApps.IO Testing Platform
easy and intuitive functional testing based on puppeteer
Emulation mode
Testing Platform based on puppeteer and puppeteer-firefox it uses these modules for emulation part.
Offers possibility to define a scenario, if you want you may fork testing scenario and build another one
In single row you may run same testing scenario under different Browsers and environments.
- ๐ณ Available emulation for 71 devices
- You may run using Chrome ๐ or Firefox Browsers ๐ฆ
- ๐ฝ You can fork a testing Scenario and make other with chages
- Easily to use Expect and Assert functionalities.
- You can easily create functionality groups and subgroups in your test
- Support for working with file Inputs
- ๐ IntelliSense Support
Why to use, describing concept
Reason for creating this library was to build a very friendly environment for functional testing, that can be easily installed without additional configurations.
Concept is based building easy to read intuitive scenarios that can be understood by anyone.
When You have 2 Testing Scenarios that are the same under specific step, you can fork them on any step, and the fork represents a clone a scenario until that step.
Example
let Scenario = new TestScenario();
Scenario
.isHeadLess(true)
.isVerbose(false) // enable to view detailed step logs
.getPage()
.goto('http://google.com', { waitUntil: "domcontentloaded" })
.wait(1000)
.describe('Functionality Group')
.goto('http://yahoo.com', { waitUntil: "domcontentloaded" })
.wait(1000)
.it(async (done, evaluate, assert, expect) => {
let title = await evaluate('document.title');
expect(title).to().be().a("string");
assert.isNotNull(title);
done();
}, "Example of checking block ยป checking title")
.goto('http://bing.com', { waitUntil: "domcontentloaded" })
.wait(1000)
.goto('http://jsdoc.app', { waitUntil: "domcontentloaded" })
.describe('Functionality SubGroup')
.goto('https://sgapps.io', { waitUntil: "domcontentloaded" })
.wait(1000)
.goto('https://github.com', { waitUntil: "domcontentloaded" })
.wait(1000)
.goto('https://npmjs.com', { waitUntil: "domcontentloaded" })
.wait(1000)
.describeClose()
.wait(1000)
.describeClose()
.close();ScreenShots
Testing multiple devices with same test scenario

Testing in Verbose mode - view all steps

Examples
API
Table of Contents
- TestingScenario
- isHeadLess
- isVerbose
- ScenarioName
- _getPage
- getPage
- setViewport
- goto
- wait
- pageEventWait
- waitForFileChooser
- waitForFunction
- waitForNavigation
- waitForSelector
- waitForXPath
- userAgent
- clearPermissionOverrides
- overridePermissions
- pageClose
- pageSetLabel
- pageReload
- pageContent
- clickOnSelector
- typeOnSelector
- tapOnSelector
- focusOnSelector
- hoverOnSelector
- evaluate
- evaluateOnSelectorAll
- evaluateOnSelectorOnlyOne
- pageEmulate
- message
- operationLabels
- operationLabelsRemove
- deactivate
- describe
- describeClose
- group
- groupClose
- injectScenario
- it
- fork
- fork
- close
- run
- TestingScenarioSetViewportOptions
- TestingScenarioGotoOptions
- TestingScenarioWaitForFunctionOptions
- TestingScenarioWaitForNavigationOptions
- TestingScenarioWaitForSelectorOptions
- TestingScenarioWaitForXPathOptions
- TestingScenarioInstancePermissions
- TestingScenarioPageCloseOptions
- TestingScenarioPageReloadOptions
- TestingScenarioPageReloadOptionsWaitUntil
- TestingScenarioClickOnSelectorOptions
- TestingScenarioTypeOnSelectorOptions
- TestingScenarioPageEmulateConfigViewport
- TestingScenarioPageEmulateDeviceName
- TestingScenarioPageEmulateDeviceConfig
- TestingScenarioPageEmulateCallbackResult
- TestingScenarioPageEmulateCallback
- TestingScenarioPageEmulateDeviceConfigOptions
- TestingScenarioPageEmulateConfig
- TestingScenarioItHandlerCallback
- assert
- expect
- expectTo
- expectToBe
- ExpectedType
- Expect.to.be.a
- Expect.to.be.notA
- Expect.to.be.instanceOf
- expectValueDescribe
TestingScenario
Type: function ()
isHeadLess
Indicates if Browser should run in headless mode
Type: function (isHeadLess): TestingScenario
isHeadLessBoolean? if parameter is not passed function will return currentisHeadLessvalue
isVerbose
Indicates if tests should run in verbose mode
Type: function (isVerbose, isHeadLess): TestingScenario
isVerboseisHeadLessBoolean? if parameter is not passed function will return currentisVerbosevalue
ScenarioName
Specify or get Current Scenario Name
Type: function (name): TestingScenario
nameString? if parameter is not passed function will return currentname
_getPage
Select from instance a page with specific index
Type: function (instance, index, PuppeteerInstance)
instanceindex(Number |"next"|"prev"| String) Page's index or 'next', 'prev', 'last' or 'first' or pages label (optional, default(instance.currentPage._getLabelName||0))PuppeteerInstance
getPage
Select from instance a page with specific index
Type: function (index): TestingScenario
index(Number |"next"|"prev"| String) Page's index or 'next', 'prev', 'last' or 'first' or pages label (optional, default(instance.currentPage._getLabelName||0))
setViewport
Applying specific viewport for device
Type: function (options): TestingScenario
goto
Opens an URL
Type: function (url, options): TestingScenario
urlString URL to navigate page to. The url should include scheme, e.g. https://.optionsTestingScenarioGotoOptions? Navigation parameters
wait
wait a priod of specified miliseconds
Type: function (timeMs): TestingScenario
timeMsNumber number of miliseconds
pageEventWait
Wait until a page will reach an event
Type: function (eventName, handler): TestingScenario
eventName("close"|"console"|"dialog"|"domcontentloaded"|"error"|"frameattached"|"framedetached"|"framenavigated"|"load"|"metrics"|"pageerror"|"popup"|"request"|"requestfailed"|"requestfinished"|"response"|"workercreated"|"workerdestroyed")handlerfunction (any): Promise? a function that can execute specific operations with data obtained on event
waitForFileChooser
add a files to inputtype="file" in instance's page
Type: function (files, selector): TestingScenario
filesArray<String> list of file paths to be added to inputselectorString CSS Selector used to identify inputtype="file"
waitForFunction
wait until browser will pageFunction will return true value
Type: function (pageFunction, options): TestingScenario
pageFunction(String | Function) Function to be evaluated in browser contextoptionsTestingScenarioWaitForFunctionOptions Optional waiting parameters
waitForNavigation
wait specific navigation state
Type: function (options): TestingScenario
optionsTestingScenarioWaitForNavigationOptions Optional waiting parameters
waitForSelector
Wait for the selector to appear in page. If at the moment of calling the method the selector already exists, the method will return immediately. If the selector doesn't appear after the timeout milliseconds of waiting, the function will throw.
Type: function (selector, options): TestingScenario
selectorString A selector of an element to wait foroptionsTestingScenarioWaitForSelectorOptions Optional waiting parameters
waitForXPath
Wait for the xpath to appear in page. If at the moment of calling the method the xpath already exists, the method will return immediately. If the xpath doesn't appear after the timeout milliseconds of waiting, the function will throw.
Type: function (xpath, options): TestingScenario
xpathString A xpath of an element to wait foroptionsTestingScenarioWaitForXPathOptions Optional waiting parameters
userAgent
Handle User agent of instance
Type: function (handler): TestingScenario
handlerfunction (userAgent): Promiseif parameter is present will handle UserAgent value
clearPermissionOverrides
Clears all permission overrides for the browser context.
Type: function (): TestingScenario
overridePermissions
Override permissions for the browser context.
Type: function (origin, permissions): TestingScenario
originString The origin to grant permissions to, e.g. "https://example.com".permissionsArray<TestingScenarioInstancePermissions> An array of permissions to grant. All permissions that are not listed here will be automatically denied.
pageClose
Close a page from instance
Type: function (options, index): TestingScenario
optionsTestingScenarioPageCloseOptions? set of optionsindexString? page's index
pageSetLabel
Set page label, for easier selecting using .getPage(label)
Type: function (label): TestingScenario
labelString label that will be set on current page
pageReload
Close a page from instance
Type: function (index, options): TestingScenario
indexString page's indexoptionsTestingScenarioPageReloadOptions set of options
pageContent
Handle User agent of instance
Type: function (handler)
handlerfunction (userAgent)if parameter is present will handle UserAgent value
clickOnSelector
This method fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to click in the center of the element. If there's no element matching selector, the method throws an error.
Type: function (selector, options): TestingScenario
selectorString A selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.optionsTestingScenarioClickOnSelectorOptions Optional parameters
typeOnSelector
Sends a keydown, keypress/input, and keyup event for each character in the text.
Type: function (selector, text, options): TestingScenario
selectorString A selector of an element to type into. If there are multiple elements satisfying the selector, the first will be used.textString A text to type into a focused element.optionsTestingScenarioTypeOnSelectorOptions Optional parameters
tapOnSelector
This method fetches an element with selector, scrolls it into view if needed, and then uses page.touchscreen to tap in the center of the element. If there's no element matching selector, the method throws an error.
Type: function (selector): TestingScenario
selectorString A selector to search for element to tap. If there are multiple elements satisfying the selector, the first will be tapped.
focusOnSelector
This method fetches an element with selector and focuses it. If there's no element matching selector, the method throws an error.
Type: function (selector): TestingScenario
selectorString A selector of an element to focus. If there are multiple elements satisfying the selector, the first will be focused.
hoverOnSelector
This method fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to hover over the center of the element. If there's no element matching selector, the method throws an error.
Type: function (selector): TestingScenario
selectorString A selector to search for element to hover. If there are multiple elements satisfying the selector, the first will be hovered.
evaluate
If the function passed to the page.evaluate returns a non-Serializable value, then page.evaluate resolves to undefined. DevTools Protocol also supports transferring some additional values that are not serializable by JSON: -0, NaN, Infinity, -Infinity, and bigint literals.
Type: function (pageFunction, handler, variables, meta): TestingScenario
pageFunction(function (Object): any| String) Function to be evaluated in the page contexthandlerfunction (result): Promise? function that receives serializable data frompageFunctionvariablesObject context passed topageFunction(optional, default{})meta
evaluateOnSelectorAll
If the function passed to the page.evaluate returns a non-Serializable value, then page.evaluate resolves to undefined. DevTools Protocol also supports transferring some additional values that are not serializable by JSON: -0, NaN, Infinity, -Infinity, and bigint literals.
Type: function (selector, pageFunction, handler, value): TestingScenario
selectorString A selector for an selecting elementpageFunction(Function | String) Function to be evaluated in the page contexthandlerfunction (result): Promise? function that receives serializable data frompageFunction, this parameter can be skippedvalueany? context passed topageFunction
Examples:
Example usage of string pageFunction.
test.evaluateOnSelectorAll('a[href]', 'element.click()');Example usage of string pageFunction with handler
test.evaluateOnSelectorAll('input[type="text"]', 'element.value', function (value) {
console.log(value);
});Example usage of string pageFunction and context
test.evaluateOnSelectorAll('input[type="email"]', 'element.value = value', 'user.email@example.com');Example usage of string pageFunction with handler and context
test.evaluateOnSelectorAll('input[type="checkbox"]', 'element.value = value; element.checked', function (isChecked) {
console.log('isChecked')
} 'On');Example usage of pageFunction.
test.evaluateOnSelectorAll('a[href]', function (element) { element.click() });Example usage of pageFunction with handler
test.evaluateOnSelectorAll(
'input[type="text"]',
function (element) {
return element.value;
}, function (value) {
console.log(value);
}
);Example usage of pageFunction and context
test.evaluateOnSelectorAll(
'input[type="email"]',
function (element, value) {
element.value = value;
},
'user.email@example.com'
);Example usage of pageFunction with handler and context
test.evaluateOnSelectorAll(
'input[type="checkbox"]',
function (element, value) {
element.value = value;
return element.checked;
},
function (isChecked) {
console.log('isChecked');
},
'On'
);evaluateOnSelectorOnlyOne
Similar with evaluateOnSelectorAll but throws an error if detected more than one element
Type: function (selector, pageFunction, handler, value): TestingScenario
selectorString A selector for an selecting elementpageFunction(Function | String) Function to be evaluated in the page contexthandlerfunction (result): Promise? function that receives serializable data frompageFunction, this parameter can be skippedvalueany? context passed topageFunction
pageEmulate
Emulates specific configuration of device
Type: function (config): TestingScenario
message
Add a specific message to last operation
Type: function (message): TestingScenario
messageString
operationLabels
Add labels to operation
Type: function (labels): TestingScenario
operationLabelsRemove
Remove labels from operation
Type: function (labels): TestingScenario
deactivate
activate or deactivate operation by adding or removing operation label "__Deactivated"
Type: function (status): TestingScenario
statusBoolean if status is true than operation will be deactivated
describe
Describe a section of testing scenario
Type: function (message): TestingScenario
messageString the message that will describe the Scenario Section
describeClose
Close Describe section of testing scenario
Type: function (message): TestingScenario
messageString message on succeed
group
Describe a group of testing scenario similar to TestingScenario.describe
Type: function (message): TestingScenario
messageString the name of group the Scenario Section
groupClose
Close Group section of testing scenario
Type: function (message): TestingScenario
messageString message on succeed
injectScenario
Inject other testing Scenario on specific step
Type: function (Scenario)
ScenarioTestingScenario
it
Assert some functionality from test
Type: function (handler, message): TestingScenario
handlerTestingScenarioItHandlerCallbackmessageString
Example:
test.goto('http://example.com')
.describe('Testing Page')
.describe('Testing Title')
.it((done, evaluate, assert, expect) => {
let title = evaluate('document.title');
expect(title).to().be().eq('Page Title', 'default page title - message shown on error');
done();
})
.describeClose()
// check if using some browsers api
.describe('Testing Title')
.it(async (done, evaluate, assert, expect) => {
let title = await evaluate(
() => {
return document.title
}
);
assert.isNotNull(title);
done();
})
.describeClose()
.describeClose()fork
Timestamp The timestamp when the metrics sample was taken. Documents Number of documents in the page. Frames Number of frames in the page. JSEventListeners Number of events in the page. Nodes Number of DOM nodes in the page. LayoutCount Total number of full or partial page layout. RecalcStyleCount Total number of page style recalculations. LayoutDuration Combined durations of all page layouts. RecalcStyleDuration Combined duration of all page style recalculations. ScriptDuration Combined duration of JavaScript execution. TaskDuration Combined duration of all tasks performed by the browser. JSHeapUsedSize Used JavaScript heap size. JSHeapTotalSize Total JavaScript heap size.
Type: function ()
fork
Fork or Clone Testing Scenario
Type: function ()
close
Close device Instance
Type: function ()
run
Run your tests under specific environment
Type: function (device, device2, device3, device4, device5, device6, device7, device8, otherDevices, devices)
device(TestingScenarioPageEmulateCallback | TestingScenarioPageEmulateDeviceConfig | TestingScenarioPageEmulateDeviceName)device2(TestingScenarioPageEmulateCallback | TestingScenarioPageEmulateDeviceConfig | TestingScenarioPageEmulateDeviceName)?device3(TestingScenarioPageEmulateCallback | TestingScenarioPageEmulateDeviceConfig | TestingScenarioPageEmulateDeviceName)?device4(TestingScenarioPageEmulateCallback | TestingScenarioPageEmulateDeviceConfig | TestingScenarioPageEmulateDeviceName)?device5(TestingScenarioPageEmulateCallback | TestingScenarioPageEmulateDeviceConfig | TestingScenarioPageEmulateDeviceName)?device6(TestingScenarioPageEmulateCallback | TestingScenarioPageEmulateDeviceConfig | TestingScenarioPageEmulateDeviceName)?device7(TestingScenarioPageEmulateCallback | TestingScenarioPageEmulateDeviceConfig | TestingScenarioPageEmulateDeviceName)?device8(TestingScenarioPageEmulateCallback | TestingScenarioPageEmulateDeviceConfig | TestingScenarioPageEmulateDeviceName)?otherDevices...anydevices(TestingScenarioPageEmulateCallback | TestingScenarioPageEmulateDeviceConfig | TestingScenarioPageEmulateDeviceName)?
TestingScenarioSetViewportOptions
Type: Object
widthNumber? device width in pixels. Default value is1920heightNumber? device height in pixels. Default value is1080deviceScaleFactorNumber? Device Scale Factor. Default value is1hasTouchBoolean? Emulate touch instead of click. Default value isfalseisLandscapeBoolean? is device in landscape mode. Default value istrueisMobileisMobile? is mobile device. Default value isfalse
TestingScenarioGotoOptions
Type: Object
waitUntil("load"|"domcontentloaded"|"networkidle0"|"networkidle2")? When to consider navigation succeeded, defaults to'load'. Given an array of event strings, navigation is considered to be successful after all events have been fired. Default value is'domcontentloaded'timeoutNumber? Maximum navigation time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods. Default value is30refererString? Referer header value. If provided it will take preference over the referer header value set by page.setExtraHTTPHeaders().
TestingScenarioWaitForFunctionOptions
Type: Object
polling("raf"|"polling"|"mutation")? An interval at which the pageFunction is executed, defaults to'raf'. If polling is a number, then it is treated as an interval in milliseconds at which the function would be executed. If polling is a string, then it can be one of the following values:-raf- to constantly execute pageFunction in requestAnimationFrame callback. This is the tightest polling mode which is suitable to observe styling changes.mutation- to execute pageFunction on every DOM mutation.
timeoutNumber? maximum time to wait for in milliseconds, Defaults to30000(30 seconds). Pass 0 to disable timeout.
TestingScenarioWaitForNavigationOptions
Type: Object
waitUntil("load"|"domcontentloaded"|"networkidle0"|"networkidle2")? When to consider navigation succeeded, defaults to'load'. Given an array of event strings, navigation is considered to be successful after all events have been fired. Events can be either:-load- consider navigation to be finished when the load event is fired.domcontentloaded- consider navigation to be finished when the DOMContentLoaded event is fired.networkidle0- consider navigation to be finished when there are no more than 0 network connections for at least 500 ms.networkidle2- consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.
timeoutNumber? maximum time to wait for in milliseconds, Defaults to30000(30 seconds). Pass 0 to disable timeout.
TestingScenarioWaitForSelectorOptions
Type: Object
visibleBoolean? wait for element to be present in DOM and to be visible, i.e. to not havedisplay: noneorvisibility: hiddenCSS properties. Defaults tofalse.hiddenBoolean? wait for element to not be found in the DOM or to be hidden, i.e. havedisplay: noneorvisibility: hiddenCSS properties. Defaults tofalse.timeoutNumber? maximum time to wait for in milliseconds, Defaults to30000(30 seconds). Pass 0 to disable timeout.
TestingScenarioWaitForXPathOptions
Type: Object
visibleBoolean? wait for element to be present in DOM and to be visible, i.e. to not havedisplay: noneorvisibility: hiddenCSS properties. Defaults tofalse.hiddenBoolean? wait for element to not be found in the DOM or to be hidden, i.e. havedisplay: noneorvisibility: hiddenCSS properties. Defaults tofalse.timeoutNumber? maximum time to wait for in milliseconds, Defaults to30000(30 seconds). Pass 0 to disable timeout.
TestingScenarioInstancePermissions
Type: ("geolocation" | "midi" | "midi-sysex" | "notifications" | "push" | "camera" | "microphone" | "background-sync" | "ambient-light-sensor" | "accelerometer" | "gyroscope" | "magnetometer" | "accessibility-events" | "clipboard-read" | "clipboard-write" | "payment-handler")
TestingScenarioPageCloseOptions
Type: Object
runBeforeUnloadBoolean Defaults tofalse. Whether to run the before unload page handlers.
TestingScenarioPageReloadOptions
Type: Object
timeoutNumber Maximum navigation time in milliseconds, defaults to30seconds, pass0to disable timeout.waitUntil(TestingScenarioPageReloadOptionsWaitUntil | Array<TestingScenarioPageReloadOptionsWaitUntil>) When to consider navigation succeeded, defaults to load. Given an array of event strings, navigation is considered to be successful after all events have been fired. Events can be either:-load- consider navigation to be finished when the load event is fired.domcontentloaded- consider navigation to be finished when the DOMContentLoaded event is fired.networkidle0- consider navigation to be finished when there are no more than 0 network connections for at least 500 ms.networkidle2- consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.
TestingScenarioPageReloadOptionsWaitUntil
When to consider navigation succeeded, defaults to load. Given an array of event strings, navigation is considered to be successful after all events have been fired. Events can be either:
load- consider navigation to be finished when the load event is fired.domcontentloaded- consider navigation to be finished when the DOMContentLoaded event is fired.networkidle0- consider navigation to be finished when there are no more than 0 network connections for at least 500 ms.networkidle2- consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.
Type: ("load" | "domcontentloaded" | "networkidle0" | "networkidle2")
TestingScenarioClickOnSelectorOptions
Type: Object
button("left"|"right"|"middle") Defaults toleft.clickCountNumber defaults to1.delayNumber Time to wait between mousedown and mouseup in milliseconds. Defaults to0.
TestingScenarioTypeOnSelectorOptions
Type: Object
delayNumber Time to wait between key presses in milliseconds. Defaults to 0.
TestingScenarioPageEmulateConfigViewport
Type: Object
widthNumber page width in pixels.heightNumber page height in pixels.deviceScaleFactorNumber Specify device scale factor (can be thought of as dpr). Defaults to 1.isMobileBoolean Whether the meta viewport tag is taken into account. Defaults to false.hasTouchBoolean Specifies if viewport supports touch events. Defaults to falseisLandscapeBoolean Specifies if viewport is in landscape mode. Defaults to false.
TestingScenarioPageEmulateDeviceName
Type: ("Blackberry PlayBook" | "Blackberry PlayBook landscape" | "BlackBerry Z30" | "BlackBerry Z30 landscape" | "Galaxy Note 3" | "Galaxy Note 3 landscape" | "Galaxy Note II" | "Galaxy Note II landscape" | "Galaxy S III" | "Galaxy S III landscape" | "Galaxy S5" | "Galaxy S5 landscape" | "iPad" | "iPad landscape" | "iPad Mini" | "iPad Mini landscape" | "iPad Pro" | "iPad Pro landscape" | "iPhone 4" | "iPhone 4 landscape" | "iPhone 5" | "iPhone 5 landscape" | "iPhone 6" | "iPhone 6 landscape" | "iPhone 6 Plus" | "iPhone 6 Plus landscape" | "iPhone 7" | "iPhone 7 landscape" | "iPhone 7 Plus" | "iPhone 7 Plus landscape" | "iPhone 8" | "iPhone 8 landscape" | "iPhone 8 Plus" | "iPhone 8 Plus landscape" | "iPhone SE" | "iPhone SE landscape" | "iPhone X" | "iPhone X landscape" | "iPhone XR" | "iPhone XR landscape" | "JioPhone 2" | "JioPhone 2 landscape" | "Kindle Fire HDX" | "Kindle Fire HDX landscape" | "LG Optimus L70" | "LG Optimus L70 landscape" | "Microsoft Lumia 550" | "Microsoft Lumia 950" | "Microsoft Lumia 950 landscape" | "Nexus 10" | "Nexus 10 landscape" | "Nexus 4" | "Nexus 4 landscape" | "Nexus 5" | "Nexus 5 landscape" | "Nexus 5X" | "Nexus 5X landscape" | "Nexus 6" | "Nexus 6 landscape" | "Nexus 6P" | "Nexus 6P landscape" | "Nexus 7" | "Nexus 7 landscape" | "Nokia Lumia 520" | "Nokia Lumia 520 landscape" | "Nokia N9" | "Nokia N9 landscape" | "Pixel 2" | "Pixel 2 landscape" | "Pixel 2 XL" | "Pixel 2 XL landscape")
TestingScenarioPageEmulateDeviceConfig
Type: Object
type("chrome"|"firefox"|"ch"|"c"|"ff"|"f")? Browser Type Firefox or Chrome, Default value is"chrome"emulateTestingScenarioPageEmulateDeviceName? emulate device name, if not set will run as in simple browser, Default value isnull.optionsTestingScenarioPageEmulateDeviceConfigOptions? Browser's options, Set of configurable options to set on the browser.
TestingScenarioPageEmulateCallbackResult
Type: Object
_errorsArray<Error> errors emitted during test_skippedNumber number of operations that were skipped in test, cause can be an emitted error_warnsNumber number of operations that got warnings_failedNumber number of operations that failed_fallenDevicesArray<TestingScenarioPageEmulateDeviceConfigOptions> list if devices that failed test
TestingScenarioPageEmulateCallback
Type: Function
TestingScenarioPageEmulateDeviceConfigOptions
Type: Object
ignoreHTTPSErrorsboolean Whether to ignore HTTPS errors during navigation. Defaults tofalse.headlessboolean Whether to run browser in headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome). Defaults totrueunless thedevtoolsoption istrue.executablePathstring Path to a Chromium or Chrome executable to run instead of the bundled Chromium. IfexecutablePathis a relative path, then it is resolved relative to current working directory.slowMonumber Slows down Puppeteer operations by the specified amount of milliseconds. Useful so that you can see what is going on.defaultViewportTestingScenarioSetViewportOptions Sets a consistent viewport for each page. Defaults to an 800x600 viewport.nulldisables the default viewport.argsArray<String> Additional arguments to pass to the browser instance. The list of Chromium flags can be found here.ignoreDefaultArgs(boolean | Array<String>) Iftrue, then do not usepuppeteer.defaultArgs(). If an array is given, then filter out the given default arguments. Dangerous option; use with care. Defaults tofalse.handleSIGINTboolean Close the browser process on Ctrl-C. Defaults totrue.handleSIGTERMboolean Close the browser process on SIGTERM. Defaults totrue.handleSIGHUPboolean Close the browser process on SIGHUP. Defaults totrue.timeoutnumber Maximum time in milliseconds to wait for the browser instance to start. Defaults to30000(30 seconds). Pass0to disable timeout.dumpioboolean Whether to pipe the browser process stdout and stderr intoprocess.stdoutandprocess.stderr. Defaults tofalse.userDataDirstring Path to a User Data Directory.envObject Specify environment variables that will be visible to the browser. Defaults toprocess.env.devtoolsboolean Whether to auto-open a DevTools panel for each tab. If this option istrue, theheadlessoption will be setfalse.pipeboolean Connects to the browser over a pipe instead of a WebSocket. Defaults tofalse.
TestingScenarioPageEmulateConfig
Type: Object
viewportTestingScenarioPageEmulateConfigViewport viewport optionsuserAgentString user agent definition
TestingScenarioItHandlerCallback
Type: Function
doneFunction function that should be executed when check id doneevaluateFunction function executed in Browser's context that return an result
assert
Type: function (expectValue, value, message, isNegated, comparingFunction)
expectValueanyvalueanymessageStringisNegatedcomparingFunction
expect
Type: function (value)
valueany
to
Type: function (): expectTo
expectTo
Type: function (value)
value
be
Type: function (): expectToBe
expectToBe
Type: function (value)
value
ExpectedType
Type: ("string" | "number" | "boolean" | "function" | "object" | "array" | "null" | "NaN" | "NUMBER_FINITE" | "NUMBER_SAFE_INTEGER" | "INFINITY" | "POSITIVE_INFINITY" | "NEGATIVE_INFINITY")
Expect.to.be.a
typeExpectedTypemessageString what to show wen conditions are not meet
Expect.to.be.notA
typeExpectedTypemessageString what to show wen conditions are not meet
Expect.to.be.instanceOf
expectValueDescribe
Type: function (value)
value
TestingScenario
Type: function ()
_getPage
Select from instance a page with specific index
Type: function (instance, index, PuppeteerInstance)
instanceindex(Number |"next"|"prev"| String) Page's index or 'next', 'prev', 'last' or 'first' or pages label (optional, default(instance.currentPage._getLabelName||0))PuppeteerInstance
getPage
Select from instance a page with specific index
Type: function (index): TestingScenario
index(Number |"next"|"prev"| String) Page's index or 'next', 'prev', 'last' or 'first' or pages label (optional, default(instance.currentPage._getLabelName||0))
setViewport
Type: function (options)
options
widthNumber? device width in pixelsheightNumber? device height in pixelsdeviceScaleFactorNumber? Device Scale FactorhasTouchBoolean? Emulate touch instead of clickisLandscapeBoolean? is device in landscape modeisMobileisMobile? is mobile device
setViewport
Applying specific viewport for device
Type: function (options): TestingScenario
optionsTestingScenarioSetViewportOptions
goto
Type: function (url, options)
urloptions
waitUntil("load"|"domcontentloaded"|"networkidle0"|"networkidle2")? When to consider navigation succeeded, defaults to'load'. Given an array of event strings, navigation is considered to be successful after all events have been fired. Events can be either:timeoutNumber? Maximum navigation time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.refererString? Referer header value. If provided it will take preference over the referer header value set by page.setExtraHTTPHeaders().
goto
Opens an URL
Type: function (url, options): TestingScenario
urlString URL to navigate page to. The url should include scheme, e.g. https://.optionsTestingScenarioGotoOptions? Navigation parameters
wait
wait a priod of specified miliseconds
Type: function (timeMs): TestingScenario
timeMsNumber number of miliseconds
pageEventWait
Wait until a page will reach an event
Type: function (eventName, handler): TestingScenario
eventName("close"|"console"|"dialog"|"domcontentloaded"|"error"|"frameattached"|"framedetached"|"framenavigated"|"load"|"metrics"|"pageerror"|"popup"|"request"|"requestfailed"|"requestfinished"|"response"|"workercreated"|"workerdestroyed")handlerfunction (any): Promise? a function that can execute specific operations with data obtained on event
waitForFileChooser
add a files to inputtype="file" in instance's page
Type: function (files, selector): TestingScenario
filesArray<String> list of file paths to be added to inputselectorString CSS Selector used to identify inputtype="file"