Tutorial: 3 - Tutorial Videos, Tips and Tricks

3 - Tutorial Videos, Tips and Tricks


Debugging and Working out Browser Automation Commands on-the-fly

TLDR - you can pause the automated browser so that you can interact with it and send it commands on the fly from your command line. To do this, you set a long timeout for your test (in milliseconds) and you use the browser debug command. This allows you to use your command line while the browser is still running, as shown in the video.

describe('STEP 1', function () {
  it('step1', async function () {
    this.timeout(4500000)
    await browser.debug()
  })
})

The video also shows some other tips and tricks for working out Webdriver IO selectors and shows a real automated journey being built from start to finish.

Video is here.


Debugging and Working out Chai Assertions for AudienceStream Trace on-the-fly

In a similar approach to pausing the browser above, you can use breakpoints in VS Code so that you can develop your chai assertions on the fly. The video shows you how. It also shows you how to work with the IE/WDIO AudienceStream Trace, and how to capture the trace output into a file so that you can then quickly iterate on your test logic without having to regenerate the trace or wait for the automation journey to complete each time.

The video also shows some other tips and tricks for working with the Trace, as well as the chai assertions, and shows a real example of trace assertion logic being built from start to finish.

Video is here.


Sauce Labs

Sauce Labs allows you to run your tests remotely on a range of browsers and operating systems. The video shows you how to get set up with Sauce Labs, and how to run the tests there. It also shows more advanced features of Sauce Labs that you may need to use, as well as a worked example of some tweaks that needed to be made to an example journey to get it to run correctly on Sauce Labs.

Video is here.


MITMProxy

MITMProxy runs on your computer and works with the SauceLabs setup to allow you to pass the network requests through the Proxy, and capture these requests for inspection and assertions. This allows you to basically write tests that prove that tags are firing correctly. The video shows you how to get set up with MITMProxy, and the end to end setup to develop assertions using it.

Video is here.


Storing Passwords in the .env file

Sometimes your automated scripts need to enter a password. If this is a sensitive password, you won't want to put this into the script directly or into any file that you might check into github. The file .env in the root of the repository is excluded from git hub. You created this as part of your setup. You can place a password there and refer to this value from your script.

In .env file

MY_WEBSITE_PASSWORD=xyz123

In your script

$('#password').setValue(process.env.MY_WEBSITE_PASSWORD)