sgapps.io-testing-platform
v1.1.17
Published
Testing Platform based on puppeteer and puppeteer-firefox. Offers possibility to define a scenario and run it under both browsers.
Downloads
24
Maintainers
Readme
🐙 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
isHeadLess
Boolean? if parameter is not passed function will return currentisHeadLess
value
isVerbose
Indicates if tests should run in verbose mode
Type: function (isVerbose, isHeadLess): TestingScenario
isVerbose
isHeadLess
Boolean? if parameter is not passed function will return currentisVerbose
value
ScenarioName
Specify or get Current Scenario Name
Type: function (name): TestingScenario
name
String? if parameter is not passed function will return currentname
_getPage
Select from instance a page with specific index
Type: function (instance, index, PuppeteerInstance)
instance
index
(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
url
String URL to navigate page to. The url should include scheme, e.g. https://.options
TestingScenarioGotoOptions? Navigation parameters
wait
wait a priod of specified miliseconds
Type: function (timeMs): TestingScenario
timeMs
Number 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"
)handler
function (any): Promise
? a function that can execute specific operations with data obtained on event
waitForFileChooser
add a files to input[type="file"] in instance's page
Type: function (files, selector): TestingScenario
files
Array<String> list of file paths to be added to inputselector
String CSS Selector used to identify input[type="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 contextoptions
TestingScenarioWaitForFunctionOptions Optional waiting parameters
waitForNavigation
wait specific navigation state
Type: function (options): TestingScenario
options
TestingScenarioWaitForNavigationOptions 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
selector
String A selector of an element to wait foroptions
TestingScenarioWaitForSelectorOptions 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
xpath
String A xpath of an element to wait foroptions
TestingScenarioWaitForXPathOptions Optional waiting parameters
userAgent
Handle User agent of instance
Type: function (handler): TestingScenario
handler
function (userAgent): Promise
if 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
origin
String The origin to grant permissions to, e.g. "https://example.com".permissions
Array<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
options
TestingScenarioPageCloseOptions? set of optionsindex
String? page's index
pageSetLabel
Set page label, for easier selecting using .getPage(label)
Type: function (label): TestingScenario
label
String label that will be set on current page
pageReload
Close a page from instance
Type: function (index, options): TestingScenario
index
String page's indexoptions
TestingScenarioPageReloadOptions set of options
pageContent
Handle User agent of instance
Type: function (handler)
handler
function (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
selector
String A selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.options
TestingScenarioClickOnSelectorOptions Optional parameters
typeOnSelector
Sends a keydown
, keypress/input
, and keyup
event for each character in the text.
Type: function (selector, text, options): TestingScenario
selector
String A selector of an element to type into. If there are multiple elements satisfying the selector, the first will be used.text
String A text to type into a focused element.options
TestingScenarioTypeOnSelectorOptions 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
selector
String 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
selector
String 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
selector
String 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 contexthandler
function (result): Promise
? function that receives serializable data frompageFunction
variables
Object 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
selector
String A selector for an selecting elementpageFunction
(Function | String) Function to be evaluated in the page contexthandler
function (result): Promise
? function that receives serializable data frompageFunction
, this parameter can be skippedvalue
any? 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', '[email protected]');
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;
},
'[email protected]'
);
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
selector
String A selector for an selecting elementpageFunction
(Function | String) Function to be evaluated in the page contexthandler
function (result): Promise
? function that receives serializable data frompageFunction
, this parameter can be skippedvalue
any? 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
message
String
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
status
Boolean if status is true than operation will be deactivated
describe
Describe a section of testing scenario
Type: function (message): TestingScenario
message
String the message that will describe the Scenario Section
describeClose
Close Describe section of testing scenario
Type: function (message): TestingScenario
message
String message on succeed
group
Describe a group of testing scenario similar to TestingScenario.describe
Type: function (message): TestingScenario
message
String the name of group the Scenario Section
groupClose
Close Group section of testing scenario
Type: function (message): TestingScenario
message
String message on succeed
injectScenario
Inject other testing Scenario on specific step
Type: function (Scenario)
Scenario
TestingScenario
it
Assert some functionality from test
Type: function (handler, message): TestingScenario
handler
TestingScenarioItHandlerCallbackmessage
String
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
width
Number? device width in pixels. Default value is1920
height
Number? device height in pixels. Default value is1080
deviceScaleFactor
Number? Device Scale Factor. Default value is1
hasTouch
Boolean? Emulate touch instead of click. Default value isfalse
isLandscape
Boolean? is device in landscape mode. Default value istrue
isMobile
isMobile? 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'
timeout
Number? 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 is30
referer
String? 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.
timeout
Number? 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.
timeout
Number? maximum time to wait for in milliseconds, Defaults to30000
(30 seconds). Pass 0 to disable timeout.
TestingScenarioWaitForSelectorOptions
Type: Object
visible
Boolean? wait for element to be present in DOM and to be visible, i.e. to not havedisplay: none
orvisibility: hidden
CSS properties. Defaults tofalse
.hidden
Boolean? wait for element to not be found in the DOM or to be hidden, i.e. havedisplay: none
orvisibility: hidden
CSS properties. Defaults tofalse
.timeout
Number? maximum time to wait for in milliseconds, Defaults to30000
(30 seconds). Pass 0 to disable timeout.
TestingScenarioWaitForXPathOptions
Type: Object
visible
Boolean? wait for element to be present in DOM and to be visible, i.e. to not havedisplay: none
orvisibility: hidden
CSS properties. Defaults tofalse
.hidden
Boolean? wait for element to not be found in the DOM or to be hidden, i.e. havedisplay: none
orvisibility: hidden
CSS properties. Defaults tofalse
.timeout
Number? 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
runBeforeUnload
Boolean Defaults tofalse
. Whether to run the before unload page handlers.
TestingScenarioPageReloadOptions
Type: Object
timeout
Number Maximum navigation time in milliseconds, defaults to30
seconds, pass0
to 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
.clickCount
Number defaults to1
.delay
Number Time to wait between mousedown and mouseup in milliseconds. Defaults to0
.
TestingScenarioTypeOnSelectorOptions
Type: Object
delay
Number Time to wait between key presses in milliseconds. Defaults to 0.
TestingScenarioPageEmulateConfigViewport
Type: Object
width
Number page width in pixels.height
Number page height in pixels.deviceScaleFactor
Number Specify device scale factor (can be thought of as dpr). Defaults to 1.isMobile
Boolean Whether the meta viewport tag is taken into account. Defaults to false.hasTouch
Boolean Specifies if viewport supports touch events. Defaults to falseisLandscape
Boolean 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"
emulate
TestingScenarioPageEmulateDeviceName? emulate device name, if not set will run as in simple browser, Default value isnull
.options
TestingScenarioPageEmulateDeviceConfigOptions? Browser's options, Set of configurable options to set on the browser.
TestingScenarioPageEmulateCallbackResult
Type: Object
_errors
Array<Error> errors emitted during test_skipped
Number number of operations that were skipped in test, cause can be an emitted error_warns
Number number of operations that got warnings_failed
Number number of operations that failed_fallenDevices
Array<TestingScenarioPageEmulateDeviceConfigOptions> list if devices that failed test
TestingScenarioPageEmulateCallback
Type: Function
TestingScenarioPageEmulateDeviceConfigOptions
Type: Object
ignoreHTTPSErrors
boolean Whether to ignore HTTPS errors during navigation. Defaults tofalse
.headless
boolean Whether to run browser in headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome). Defaults totrue
unless thedevtools
option istrue
.executablePath
string Path to a Chromium or Chrome executable to run instead of the bundled Chromium. IfexecutablePath
is a relative path, then it is resolved relative to current working directory.slowMo
number Slows down Puppeteer operations by the specified amount of milliseconds. Useful so that you can see what is going on.defaultViewport
TestingScenarioSetViewportOptions Sets a consistent viewport for each page. Defaults to an 800x600 viewport.null
disables the default viewport.args
Array<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
.handleSIGINT
boolean Close the browser process on Ctrl-C. Defaults totrue
.handleSIGTERM
boolean Close the browser process on SIGTERM. Defaults totrue
.handleSIGHUP
boolean Close the browser process on SIGHUP. Defaults totrue
.timeout
number Maximum time in milliseconds to wait for the browser instance to start. Defaults to30000
(30 seconds). Pass0
to disable timeout.dumpio
boolean Whether to pipe the browser process stdout and stderr intoprocess.stdout
andprocess.stderr
. Defaults tofalse
.userDataDir
string Path to a User Data Directory.env
Object Specify environment variables that will be visible to the browser. Defaults toprocess.env
.devtools
boolean Whether to auto-open a DevTools panel for each tab. If this option istrue
, theheadless
option will be setfalse
.pipe
boolean Connects to the browser over a pipe instead of a WebSocket. Defaults tofalse
.
TestingScenarioPageEmulateConfig
Type: Object
viewport
TestingScenarioPageEmulateConfigViewport viewport optionsuserAgent
String user agent definition
TestingScenarioItHandlerCallback
Type: Function
done
Function function that should be executed when check id doneevaluate
Function function executed in Browser's context that return an result
assert
Type: function (expectValue, value, message, isNegated, comparingFunction)
expectValue
anyvalue
anymessage
StringisNegated
comparingFunction
expect
Type: function (value)
value
any
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
type
ExpectedTypemessage
String what to show wen conditions are not meet
Expect.to.be.notA
type
ExpectedTypemessage
String 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)
instance
index
(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
width
Number? device width in pixelsheight
Number? device height in pixelsdeviceScaleFactor
Number? Device Scale FactorhasTouch
Boolean? Emulate touch instead of clickisLandscape
Boolean? is device in landscape modeisMobile
isMobile? is mobile device
setViewport
Applying specific viewport for device
Type: function (options): TestingScenario
options
TestingScenarioSetViewportOptions
goto
Type: function (url, options)
url
options
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:timeout
Number? 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.referer
String? 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
url
String URL to navigate page to. The url should include scheme, e.g. https://.options
TestingScenarioGotoOptions? Navigation parameters
wait
wait a priod of specified miliseconds
Type: function (timeMs): TestingScenario
timeMs
Number 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"
)handler
function (any): Promise
? a function that can execute specific operations with data obtained on event
waitForFileChooser
add a files to input[type="file"] in instance's page
Type: function (files, selector): TestingScenario
files
Array<String> list of file paths to be added to inputselector
String CSS Selector used to identify input[type="file"]