Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions lib/core/engine/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ export class Commands {
* Navigates to a specified URL and handles additional setup for a page visit.
* @async
* @example await commands.navigate('https://www.example.org');
* @type {Function}
* @param {string} url - The URL to navigate to.
* @throws {Error} Throws an error if navigation or setup fails.
* @returns {Promise<void>} A promise that resolves when the navigation and setup are
* @type {(url: string) => Promise<void>}
*/
this.navigate = measure._navigate.bind(measure);

Expand All @@ -244,15 +244,15 @@ export class Commands {
* Add a text that will be an error attached to the current page.
* @example await commands.error('My error message');
* @param {string} message - The error message.
* @type {Function}
* @type {(message: string) => void}
*/
this.error = measure._error.bind(measure);

/**
* Mark this run as an failure. Add a message that explains the failure.
* @example await commands.markAsFailure('My failure message');
* @param {string} message - The message attached as a failure
* @type {Function}
* @type {(message: string) => void}
*/
this.markAsFailure = measure._failure.bind(measure);

Expand Down Expand Up @@ -485,7 +485,6 @@ export class Commands {
* @param {string} text - The text to type into the element.
* @returns {Promise<void>} A promise that resolves when the text has been added.
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.type = async (selector, text) => {
return this.addText(selector, text);
Expand All @@ -502,7 +501,7 @@ export class Commands {
* @param {boolean} [options.visible=false] - If true, waits for the element to be visible.
* @returns {Promise<WebElement>} A promise that resolves to the WebElement found.
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
* @type {(selector: string, options?: { timeout?: number, visible?: boolean }) => Promise<import('selenium-webdriver').WebElement>}
*/
this.find = this.element.find.bind(this.element);

Expand All @@ -518,7 +517,6 @@ export class Commands {
* @param {Object} [existsOptions] - Options.
* @param {number} [existsOptions.timeout=0] - Maximum time to wait for the element. Default 0 (no wait).
* @returns {Promise<boolean>} True if the element exists.
* @type {Function}
*/
this.exists = async (selector, existsOptions = {}) => {
const { locator } = parseSelector(selector);
Expand Down Expand Up @@ -552,7 +550,6 @@ export class Commands {
* @param {string} selector - The CSS selector or prefixed selector.
* @returns {Promise<string>} The visible text content.
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.getText = async selector => {
const element = await findElement(selector);
Expand All @@ -567,7 +564,6 @@ export class Commands {
* @param {string} selector - The CSS selector or prefixed selector.
* @returns {Promise<string>} The element's value.
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.getValue = async selector => {
const element = await findElement(selector);
Expand All @@ -581,7 +577,6 @@ export class Commands {
* @param {string} selector - The CSS selector or prefixed selector.
* @returns {Promise<boolean>} True if the element is visible.
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.isVisible = async selector => {
const element = await findElement(selector);
Expand All @@ -597,7 +592,6 @@ export class Commands {
* @param {string} attribute - The attribute name.
* @returns {Promise<string>} The attribute value.
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.getAttribute = async (selector, attribute) => {
const element = await findElement(selector);
Expand All @@ -611,7 +605,6 @@ export class Commands {
* @param {string} selector - The CSS selector or prefixed selector.
* @returns {Promise<boolean>} True if the element is enabled.
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.isEnabled = async selector => {
const element = await findElement(selector);
Expand All @@ -625,7 +618,6 @@ export class Commands {
* @param {string} selector - The CSS selector or prefixed selector.
* @returns {Promise<boolean>} True if the element is checked/selected.
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.isChecked = async selector => {
const element = await findElement(selector);
Expand All @@ -640,7 +632,6 @@ export class Commands {
* @param {string} selector - The CSS selector or prefixed selector.
* @returns {Promise<void>} A promise that resolves when the element is cleared.
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.clear = async selector => {
const { locator } = parseSelector(selector);
Expand All @@ -665,7 +656,6 @@ export class Commands {
* @param {Object<string, string>} fields - An object mapping selectors to values.
* @returns {Promise<void>} A promise that resolves when all fields are filled.
* @throws {Error} Throws an error if any element is not found.
* @type {Function}
*/
this.fill = async fields => {
for (const [selector, text] of Object.entries(fields)) {
Expand All @@ -682,7 +672,6 @@ export class Commands {
* @param {string} selector - The CSS selector or prefixed selector.
* @returns {Promise<void>}
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.hover = async selector => {
return this.mouse.moveTo(selector);
Expand All @@ -697,7 +686,6 @@ export class Commands {
* @example await commands.press('Escape');
* @param {string} key - The key name to press (e.g. 'Enter', 'Tab', 'Escape').
* @returns {Promise<void>}
* @type {Function}
*/
this.press = async key => {
const keyValue = webdriver.Key[key.toUpperCase()] || key;
Expand All @@ -711,7 +699,6 @@ export class Commands {
* @async
* @example const title = await commands.getTitle();
* @returns {Promise<string>} The page title.
* @type {Function}
*/
this.getTitle = async () => {
return browser.getDriver().getTitle();
Expand All @@ -722,7 +709,6 @@ export class Commands {
* @async
* @example const url = await commands.getUrl();
* @returns {Promise<string>} The current URL.
* @type {Function}
*/
this.getUrl = async () => {
return browser.getDriver().getCurrentUrl();
Expand All @@ -736,7 +722,6 @@ export class Commands {
* @param {string} selector - The CSS selector or prefixed selector.
* @returns {Promise<void>}
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.check = async selector => {
const element = await findElement(selector);
Expand All @@ -754,7 +739,6 @@ export class Commands {
* @param {string} selector - The CSS selector or prefixed selector.
* @returns {Promise<void>}
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.uncheck = async selector => {
const element = await findElement(selector);
Expand All @@ -772,7 +756,6 @@ export class Commands {
* @param {string} selector - The CSS selector or prefixed selector.
* @returns {Promise<void>}
* @throws {Error} Throws an error if the element is not found.
* @type {Function}
*/
this.scrollIntoView = async selector => {
const element = await findElement(selector);
Expand All @@ -795,7 +778,6 @@ export class Commands {
* @param {number} [urlOptions.timeout=10000] - Maximum time to wait in milliseconds.
* @returns {Promise<void>}
* @throws {Error} Throws an error if the URL does not match within the timeout.
* @type {Function}
*/
this.waitForUrl = async (pattern, urlOptions = {}) => {
const timeout = urlOptions.timeout ?? 10_000;
Expand Down
Loading
Loading