diff --git a/README.md b/README.md index 2d36a76..da7dc11 100644 --- a/README.md +++ b/README.md @@ -372,12 +372,12 @@ const testableUtils = require('testable-utils'); const fireNow = testableUtils.isLocal || testableUtils.isSmokeTest; describe('Load Url Requested in Event', function() { - it('should load url', function() { + it('should load url', async () => { browser.testableLogInfo('Waiting on load-url event'); // no timeout (0), use Google url for local/smoke testing const url = browser.testableWaitForEvent('load-url', 0, 'https://google.com'); - browser.url(url); - browser.testableScreenshot('Requested Url'); + await browser.url(url); + await browser.testableScreenshot('Requested Url'); }); }); ``` @@ -435,7 +435,7 @@ Note that all the Webdriver.io commands can be used in a synchronous fashion. ### Screenshots -One command that has no `testable-utils` equivalent is `browser.testableScreenshot(name)`. This command takes a screenshot and puts it in the output directory to be collected as part of the test results. It also includes a prefix to make it easier to identify: `[region]-[chunk]-[user]-[iteration]-[name].png`. Tests are broken up into chunks, and within each chunk users and iterations are numbered starting at 0. So for example `us-east-1-123-0-0-MyHomePage.png` would be chunk id 123, first user, first iteration, image name `MyHomePage`. +One command that has no `testable-utils` equivalent is `await browser.testableScreenshot(name)`. This command takes a screenshot and puts it in the output directory to be collected as part of the test results. It also includes a prefix to make it easier to identify: `[region]-[chunk]-[user]-[iteration]-[name].png`. Tests are broken up into chunks, and within each chunk users and iterations are numbered starting at 0. So for example `us-east-1-123-0-0-MyHomePage.png` would be chunk id 123, first user, first iteration, image name `MyHomePage`. ### Command Mappings diff --git a/index.d.ts b/index.d.ts index 0394970..de063a1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -170,7 +170,7 @@ declare global { testableBarrier: (name: string, value?: any) => any; testableInfo: () => any; - testableScreenshot: (name: string) => any; + testableScreenshot: (name: string) => Promise; testableStopwatch: (code: Function, metricName?: string, resource?: string) => any; testableWaitForEvent: (eventName: string, timeout?: number, defaultVal?: any) => any; diff --git a/lib/wdio-commands.js b/lib/wdio-commands.js index 357df9d..29d68a9 100644 --- a/lib/wdio-commands.js +++ b/lib/wdio-commands.js @@ -130,9 +130,9 @@ function registerInfoCommands(browser, info, isLocal) { browser.addCommand('testableInfo', function () { return info; }); - browser.addCommand('testableScreenshot', function(name) { + browser.addCommand('testableScreenshot', async function(name) { const path = pathModule.join(process.env.OUTPUT_DIR || '.', name + '.png'); - browser.saveScreenshot(path); + await browser.saveScreenshot(path); return path; }); } diff --git a/package.json b/package.json index 3c0f59e..90272ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "testable-utils", - "version": "0.5.11", + "version": "0.5.12", "description": "Utilities for Testable scripts", "author": "Avi Stramer", "keywords": [