Skip to main content

The tips

76 short, tested tips. Each one automates one use case, in every framework we cover, and CI runs every example.

Intermediatefundamentals

How to Test Two Users at Once

A chat, a shared document or a multiplayer game only works when one user sees what another user does. One test can start two browsers, one for each user, and check that a message sent by one user reaches the other.

browser contexts · multiple browsers · multiple users · websockets
Beginnerfundamentals

How to Print a Page to PDF

Invoices, tickets and reports are often printed or saved as PDF. The test can print the page to a PDF, without the print dialog, to check the printed version or to keep it as a record of the run.

pdf · print
Intermediateremote

How to Check Screenshots with Sauce Labs Visual

Comparing screenshots in the test code means keeping baselines for every browser and operating system, and reviewing the differences by hand. Sauce Labs Visual stores the baselines, compares the snapshots, and shows the changes for review.

sauce labs · screenshots · visual testing
Intermediatefundamentals

How to Compare Screenshots of an Element

A button that moves a few pixels, a wrong color, or a missing logo pass every functional check. A test that compares screenshots of an element, pixel by pixel, notices them.

screenshots · visual testing
Intermediateremote

How To Run Your Tests Headlessly with Chrome

A Continuous Integration (CI) server usually has no display for the browser to open a window in. Chrome can run headless (without a window), so the tests run there with no extra tools.

chrome · headless
Intermediateresources

The Mobile Testing Pyramid

There are loads of trade-offs when it comes to mobile testing. But by learning to use all layers of the mobile testing pyramid to your advantage you can gain the fast feedback that is required in modern CI/CD environments.

mobile · pyramid
Intermediatefundamentals

How to Reuse a Login Across Tests

Logging in through the form at the start of every test makes the suite slow, and every test fails when the login page has a problem. The test suite can log in once, keep the session cookie, and start each test already logged in.

cookies · login · storage state · test setup
Beginnertools

Safari Driver

Safari comes with its own driver, safaridriver, on every Mac. It needs two settings turned on once, and then Selenium runs our tests on Safari like on any other browser.

different browsers · drivers · safari · safaridriver
Intermediateremotetools

How To Upload Files to a Remote Browser

When the browser runs on another machine (a Selenium Grid, a cloud provider), it cannot see the files on our machine. Here is how to send a file to it and upload it.

cloud · file upload · files · grid · sauce labs · selenium grid · uploading