Methods
executeCommand(log, errorMessage, identifier, fn, browseropt) → {Promise.<*>}
Shared error handling wrapper for command methods. Most command methods follow the same try/catch pattern: log.error + log.verbose + throw new Error. This helper eliminates that boilerplate.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
log | Object | The logger instance. | |
errorMessage | string | printf-style message (with %s placeholder). | |
identifier | string | | Value to interpolate into the message, or undefined if none. | |
fn | function | The async function to execute. | |
browser | Object | <optional> | Optional browser instance. When provided, the current page URL is appended to the error message. |
Returns:
The return value of fn.
- Type:
- Promise.<*>
parseSelector(selector) → {Object}
Parses a selector string into a Selenium By locator. Supports prefix-based strategies: - 'id:value' -> By.id('value') - 'xpath:expression' -> By.xpath('expression') - 'name:value' -> By.name('value') - 'text:value' -> By.xpath('//*[normalize-space(text())="value"]') - 'link:value' -> By.xpath('//a[text()="value"]') - 'class:value' -> By.className('value') - No prefix -> By.css(selector) (CSS selector is the default)
Parameters:
| Name | Type | Description |
|---|---|---|
selector | string | The selector string to parse. |
Returns:
The parsed locator and a human-readable description.
- Type:
- Object
(async) timeout(promise, ms, errorMessage)
Timeout a promise after ms. Use promise.race to compete about the timeout and the promise.
Parameters:
| Name | Type | Description |
|---|---|---|
promise | promise | the promise to wait for |
ms | int | how long in ms to wait for the promise to fininsh |
errorMessage | string | the error message in the Error if we timeouts |