Skip to main content
Version: 9.0.0

Util actions

eval

Method allowing to interact in client context.

ParameterTypeDescription
fnfunction
argfunction

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.

ParameterTypeDescription
fnfunction
argfunction

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.

ParameterTypeDescription
fnfunction
argfunction

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.

ParameterTypeDescription
timeoutnumberTime 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.

ParameterTypeDescription
optionsWaitForConditionOptionsMethod options.

WaitForConditionOptions

ParameterTypeDescription
conditionbooleanCondition to fulfill. Condition is fulfilled when it equals true.
intervalnumberTime interval between retries in milliseconds.
timeoutnumberTimeout of the method in milliseconds.
retriesnumberNumber of retries.
backoffFIXED / EXPONENTIAL / LINEARValue used to determine the wait time between successive retries.
throwOnErrorbooleanIf true, the code throws an error when the condition is not met within the timeout.
maxBackOffnumberMaximum value of the backoff in milliseconds.
errorMessagestringError message to be thrown if the condition is not met within the timeout.
overrideErrorMessagestringOverride the error message thrown by the Test Maker.
retryMessagestringRetry 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.

ParameterTypeDescription
selectorselectorTypeSelector 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.

ParameterTypeDescription
selectorselectorTypeSelector 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.

ParameterTypeDescription
selectorselectorTypeSelector 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.

ParameterTypeDescription
selectorselectorTypeSelector 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.

ParameterTypeDescription
selectorselectorTypeSelector of the targeted element.
checksActionabilityCheckTypes[]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.

ParameterTypeDescription
selectorselectorTypeSelector of the targeted element.
optionsWaitFrameToLoadOptionsMethod options.

WaitFrameToLoadOptions

ParameterTypeDescription
condition"readyStateComplete" / "domContentLoaded" / "loaded" / "src"Condition for the frame to load.
ignoreSrcbooleanIgnore source check.
childSelectorstringChild 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.

ParameterTypeDescription
waitForVisualStateOptionsWaitForVisualStateOptionsMethod options.

WaitForVisualStateOptions

ParameterTypeDescription
baseImagePathstring / (() => Promise<string>)Reference image path.
testImagePathstring / (() => Promise<string>)Image path to compare with reference image.
diffImagePathstring / (() => Promise<string>)Path of the generated difference image.
mismatchThresholdnumberMismatch threshold.
retryOptionsWaitForConditionOptionsRetry 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 TypeDescription
ControllerPromiseA 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.

ParameterTypeDescription
pathstringStorage path of the screenshot.
optionsobjectMethod options.

options

ParameterTypeDescription
fullPagebooleanApply to full page.

Usage

await I.takeScreenshot('./screenshots/example.png', { fullPage: true });

takeSelectorScreenshot

Method allowing to take a selector screenshot.

ParameterTypeDescription
selectorselectorTypeSelector of the targeted element.
pathstringStorage path of the screenshot.

Usage

await I.takeSelectorScreenshot('.example-selector', './screenshots/example.png');

recordVideo

Method allowing to record video.

ParameterTypeDescription
optionsRecordVideoOptions

RecordVideoOptions

ParameterTypeDescription
pathstringVideo storage path.
qualitynumberVideo quality.
widthnumberVideo width.
heightnumberVideo height.
extraOptionsRecord<string, any>Options.

returns

ParameterTypeDescription
idstringVideo 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

ParameterType
'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.

ParameterTypeDescription
metadataRecord<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.

ParameterTypeDescription
{ 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.

ParameterTypeDescription
{ 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.

ParameterTypeDescription
{ 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.

ParameterTypeDescription
{ 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.

ParameterTypeDescription
{ 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>` });