Util actions
eval
Method allowing to interact in client context.
Parameter | Type | Description |
---|---|---|
fn | function | |
arg | function |
Basic Usage
await I.eval(() => {
console.log(`hello from client`);
})
evalInCurrentWindowMainFrame
Method allowing to interact in client context inside the main frame of the current window.
Parameter | Type | Description |
---|---|---|
fn | function | |
arg | function |
Basic Usage
const elementSelector = `myElementID`;
await I.evalInCurrentWindowMainFrame((element)=> {
return document.getElementById(element).innerText
},
elementSelector
);
evalInAllFrames
Method allowing to interact in client context inside all frames.
Parameter | Type | Description |
---|---|---|
fn | function | |
arg | function |
Basic Usage
const elementSelector = `myElementID`;
await I.evalInAllFrames((element)=> {
return document.getElementById(element).innerText
},
elementSelector
);
getClientInfo
Method allowing to retrieve client information.
Client information
name: string;
version: string;
headless: boolean;
platform: string;
userAgent: string;
prettyUserAgent: string;
type: `mobile` | `web` | `desktop` | `unit`;
engine: {
name: string;
version: string;
};
os: {
name: string;
version: string;
};
wait
Method allowing to wait for a certain amount of time.
Parameter | Type | Description |
---|---|---|
timeout | number | Time duration in milliseconds. |
Basic Usage
await I.wait(3000);
This example will pause the execution of the script for 3000 milliseconds (3 seconds) before moving on to the next step.
waitForCondition
Method allowing to wait for a certain amount of time until a condition is met.
Parameter | Type | Description |
---|---|---|
options | WaitForConditionOptions | Method options. |
WaitForConditionOptions
Parameter | Type | Description |
---|---|---|
condition | boolean | Condition to fulfill. Condition is fulfilled when it equals true . |
interval | number | Time interval between retries in milliseconds. |
timeout | number | Timeout of the method in milliseconds. |
retries | number | Number of retries. |
backoff | FIXED / EXPONENTIAL / LINEAR | Value used to determine the wait time between successive retries. |
throwOnError | boolean | If true, the code throws an error when the condition is not met within the timeout. |
maxBackOff | number | Maximum value of the backoff in milliseconds. |
errorMessage | string | Error message to be thrown if the condition is not met within the timeout. |
overrideErrorMessage | string | Override the error message thrown by the Test Maker. |
retryMessage | string | Retry message to be logged when retries are made. |
Basic Usage
await I.waitForCondition({
condition: () => {
// Your condition logic here
// This condition should return a boolean value
return conditionIsMet;
},
interval: 1000, // Check the condition every 1 second
timeout: 10000, // Give up after 10 seconds if condition is not met
retries: 3, // Retry the condition 3 times if not met
throwOnError: false, // Do not throw error if condition is not met within timeout
errorMessage: "Condition not met within timeout", // Custom error message if condition is not met within timeout
});
This example demonstrates how to use the waitForCondition
method to wait until a specified condition is met within a given timeout period. Adjust the condition
function and other options according to your specific use case.
Basic Usage
await I.waitForCondition({
condition: async () => {
let flag = await Selector(`myElementID`, {timeout: 2000}).exists;
return !flag;
},
interval: 50,
timeout: 10000,
retryMessage: `Waiting for the selector To exist`,
});
waitForSelectorToExist
Method allowing to wait for a selector to exist.
Parameter | Type | Description |
---|---|---|
selector | selectorType | Selector of the targeted element. |
Usage
await I.waitForSelectorToExist(selector);
This method waits until the specified selector exists in the DOM. The selector
parameter specifies the targeted element to wait for.
waitForSelectorToNotExist
Method allowing to wait for a selector to cease to exist.
Parameter | Type | Description |
---|---|---|
selector | selectorType | Selector of the targeted element. |
Usage
await I.waitForSelectorToNotExist(selector);
This method waits until the specified selector ceases to exist in the DOM. The selector
parameter specifies the targeted element to wait for its absence.
waitForSelectorToBeVisible
Method allowing to wait for a selector to be visible.
Parameter | Type | Description |
---|---|---|
selector | selectorType | Selector of the targeted element. |
Usage
await I.waitForSelectorToBeVisible(selector);
This method waits until the specified selector becomes visible in the DOM. The selector
parameter specifies the targeted element to wait for its visibility.
waitForSelectorToBeInvisible
Method allowing to wait for a selector to be invisible.
Parameter | Type | Description |
---|---|---|
selector | selectorType | Selector of the targeted element. |
Usage
await I.waitForSelectorToBeInvisible(selector);
This method waits until the specified selector becomes invisible in the DOM. The selector
parameter specifies the targeted element to wait for its invisibility.
waitForSelectActionabilityCheck
Method allowing to check the state attributes of a selector.
Parameter | Type | Description |
---|---|---|
selector | selectorType | Selector of the targeted element. |
checks | ActionabilityCheckTypes[] | Actionability check types. |
ActionabilityCheckTypes[]
ActionabilityCheckTypes = `attached` | `stable` | `visible` | `enabled` | `editable`;
Basic Usage
await I.waitForSelectActionabilityCheck("mySelector", [`enabled`])
waitForFrameToLoad
Method allowing to wait for a frame to load.
Parameter | Type | Description |
---|---|---|
selector | selectorType | Selector of the targeted element. |
options | WaitFrameToLoadOptions | Method options. |
WaitFrameToLoadOptions
Parameter | Type | Description |
---|---|---|
condition | "readyStateComplete" / "domContentLoaded" / "loaded" / "src" | Condition for the frame to load. |
ignoreSrc | boolean | Ignore source check. |
childSelector | string | Child selector to check. |
Usage
await I.waitForFrameToLoad(selector, options);
This method waits until a frame identified by the specified selector loads completely based on the provided options. The selector
parameter specifies the targeted frame, and the options
parameter allows you to customize the waiting conditions.
Basic Usage
await I.waitForFrameToLoad(`myElementID`,{ condition:"readyStateComplete",ignoreSrc:true,childSelector: "mychildSelector"})
waitForVisualState
Method allowing to wait for specific visual state.
Parameter | Type | Description |
---|---|---|
waitForVisualStateOptions | WaitForVisualStateOptions | Method options. |
WaitForVisualStateOptions
Parameter | Type | Description |
---|---|---|
baseImagePath | string / (() => Promise<string>) | Reference image path. |
testImagePath | string / (() => Promise<string>) | Image path to compare with reference image. |
diffImagePath | string / (() => Promise<string>) | Path of the generated difference image. |
mismatchThreshold | number | Mismatch threshold. |
retryOptions | WaitForConditionOptions | Retry options for waiting. |
Basic Usage
await I.waitForVisualState({
baseImagePath:"./src/assets/images/baseimg.png.jpg" ,
testImagePath: "./src/assets/images/testimg.png",
diffImagePath: "./src/assets/images/diffimg.png",
mismatchThreshold: 100
})
debugger
Method allowing to enter debugger mode.
Return Type | Description |
---|---|
ControllerPromise | A promise representing the debugger operation. |
Usage
await I.debugger();
This method triggers the debugger, allowing you to pause the execution of the test and inspect the state of the application or debug any issues. Press f
key to resume test execution.
takeScreenshot
Method allowing to take a screenshot.
Parameter | Type | Description |
---|---|---|
path | string | Storage path of the screenshot. |
options | object | Method options. |
options
Parameter | Type | Description |
---|---|---|
fullPage | boolean | Apply to full page. |
Usage
await I.takeScreenshot('./screenshots/example.png', { fullPage: true });
takeSelectorScreenshot
Method allowing to take a selector screenshot.
Parameter | Type | Description |
---|---|---|
selector | selectorType | Selector of the targeted element. |
path | string | Storage path of the screenshot. |
Usage
await I.takeSelectorScreenshot('.example-selector', './screenshots/example.png');
recordVideo
Method allowing to record video.
Parameter | Type | Description |
---|---|---|
options | RecordVideoOptions |
RecordVideoOptions
Parameter | Type | Description |
---|---|---|
path | string | Video storage path. |
quality | number | Video quality. |
width | number | Video width. |
height | number | Video height. |
extraOptions | Record<string, any> | Options. |
returns
Parameter | Type | Description |
---|---|---|
id | string | Video id. |
pause | () => Promise<void> | |
resume | () => Promise<void> | |
stop | () => Promise<void> |
Usage
const options: RecordVideoOptions = {
path: './videos/example.mp4',
// Other options are optional and can be included if needed
quality: 0.8,
width: 1280,
height: 720,
extraOptions: { additionalOption: 'value' },
};
const { id, pause, resume, stop } = await I.recordVideo(options);
// Use the 'id' to refer to the recorded video, and the functions 'pause', 'resume', and 'stop' to control recording.
emulateNetworkConditions
Method allowing to emulate network conditions.
options
Parameter | Type |
---|---|
'offline' | NetworkCondition |
'online' | NetworkCondition |
'GPRS' | NetworkCondition |
'56K Dial-up' | NetworkCondition |
'Mobile EDGE' | NetworkCondition |
'2G Regular' | NetworkCondition |
'2G Good' | NetworkCondition |
'3G Slow' | NetworkCondition |
'3G Regular' | NetworkCondition |
'3G Good' | NetworkCondition |
'4G/LTE Regular' | NetworkCondition |
'DSL' | NetworkCondition |
'Cable 5Mbps' | NetworkCondition |
'10Mbps shared' | NetworkCondition |
'FIOS' | NetworkCondition |
'Wi-Fi' | NetworkCondition |
Basic Usage
await I.emulateNetworkConditions("4G/LTE Regular")
getClientLogs
Method allowing to retrieve the client log information.
Basic Usage
await I.getClientLogs()
getScrollPosition
Method allowing to retrieve the scroll position.
Basic Usage
let scrollPosition = await I.getScrollPosition();
getTitle
Method allowing to retrieve the title of the window.
Basic Usage
await I.goto('http://my-website-url.com');
let title = await I.getTitle();
await I.expect(title).toEqual('Website title');
getSource
Method allowing to retrieve page source code.
Basic Usage
await I.goto('http://the-internet.herokuapp.com/abtest');
let pageSource = await I.getSource();
await I.expect(pageSource).toContain(`A/B Test`);
getCurrentUrl
Method allowing to retrieve the current URL.
Basic Usage
await I.goto('http://my-website-url.com');
let currentUrl = await I.getCurrentUrl();
await I.expect(currentUrl).toEqual('http://my-website-url.com');
addMetaData
Method allowing to add MetaData to the report.
Parameter | Type | Description |
---|---|---|
metadata | Record<string, any> | Enter the metadata that should be added to the report. |
Basic Usage
Note that metadata do not show in reporter unless you prefix it with "reporter:". Since metadata are generic metadata they can be used for anything and not just reporter.
const metadataValue = "This is the metadata"
await I.addMetaData(
{
"reporter:metaDataTitle":metadataValue
}
)
addReporterAttachment
Method allowing to add an attachment to the report.
Parameter | Type | Description |
---|---|---|
{ name, content, path, mimeType } | { name?: string; content?: Buffer / string; path?: string;, mimeType: AttachmentTypes; } | Enter the optional name, content and path of your attachment and enter the type of file. |
AttachmentTypes
string | 'text/plain' | 'text/html' | 'application/xml' | 'text/csv' | 'text/tab-separated-values' | 'text/css' | 'text/uri-list' | 'image/svg+xml' | 'application/json' | 'video/mp4' | 'video/webm' | 'image/jpeg' | 'image/png';
addScreenshotReporterAttachment
Method allowing to attach a screenshot to the report.
Parameter | Type | Description |
---|---|---|
{ title, filepath } | { title?:string; filepath:string } | Enter the optional title of your screenshot attachment enter the screenshot file path. |
Basic Usage
await I.addScreenshotReporterAttachment({ title: `Attached Screenshot`, filePath: `./dist/attachedScreenshot/${Date.now()}.jpg` });
addImageReporterAttachment
Method allowing to attach an image to the report.
Parameter | Type | Description |
---|---|---|
{ title, filepath } | { title?:string; filepath:string } | Enter the optional title of your image attachment and enter the image file path. |
Basic Usage
await I.addImageReporterAttachment({ title: 'imgReporterTest', filePath: `./src/assets/images/base_image.jpg` });
addTextReporterAttachment
Method allowing to attach text to the report.
Parameter | Type | Description |
---|---|---|
{ title, content } | { title?:string; filepath:string } | Enter the optional title of your text attachment and enter the text content. |
Basic Usage
await I.addTextReporterAttachment({ title: 'imgReporterTest', content: `My testing test` });
addHtmlReporterAttachment
Method allowing to attach html to the report.
Parameter | Type | Description |
---|---|---|
{ title, content } | { title?:string; content:string } | Enter the optional title of you html attachment and enter the html content. |
Basic Usage
await I.addHtmlReporterAttachment({ title: 'htmlReporterTest', content: `<td>My test Codel</td>` });