How to Run Automated Web Tests on the Sauce Labs Continuous Testing Cloud

Welcome to Sauce Labs the world’s largest Continuous Testing Cloud
for web and mobile applications Sauce Labs helps you succeed in the modern,
digital era, by giving you the digital confidence that you’re always delivering the best possible
user experience to your customers. In this video, we’ll show you how to set
up and run automated web tests on the Sauce Labs Continuous Testing cloud. We have two tests we’ll run against an application
called “Sauce demo”, which is a typical desktop web app that we’re accessing here from a laptop
running the Chrome browser. The first thing we’ll need to create our test
is a programming language. We’re using Python and the PyTest testing
framework for that. The second thing we’ll need is a Remote Web
Driver for automating our tests actions, and we’re using selenium to handle the automation. So let’s take a look at what our tests will do. The first test visits the site and verifies
that the browser title is “Swag Labs.” The second test visits the site, enters our
username and password, clicks the login button, then verifies that we’re logged in by looking for the shopping cart container item on the page. Now let’s take a look at the prerequisites
for running our tests using selenium on Sauce Labs The sauceOptions section includes required
configuration settings for Selenium, including the operating system our tests will run on,
and the browser version we’ll be using. We’re also passing in the test name. The desired capabilities section tells Sauce
Labs which browser and operating system Sauce Labs should spin up to run our tests. We’re testing against Chrome and Windows 10,
but Sauce Labs also provides hundreds of other device, OS and browser combinations,
in addition to real devices in the cloud. We’ll also need our Sauce Labs
username and access key to run our test. Our username is the name we used to create
our Sauce Labs account, and our access key can be found in the Sauce Labs dashboard,
under “My account”, “User Settings.” You’ll want to protect your access key just
like you would any other password – so keep it private and don’t check it into version
control where others can access it. A best practice is to read your username and
access key using environment variables, which is what we’re doing here. Two additional features that
are unique to Sauce Labs are extended debugging and Sauce Performance. Extended debugging provides additional information
about network requests during testing, and Sauce Performance builds
detailed front-end performance metrics and root-cause analysis into our tests. We’re setting our driver to WebDriver remote,
which enables our tests to connect remotely to the Sauce Labs Continuous Testing Cloud, and finally, we’re telling Sauce Labs to show results about whether our tests pass or fail. So with all of those pieces in place,
let’s run our test. We’ll kickoff the test, then switch to the
Sauce Labs dashboard, where we can that our first test has already completed, and our
second test is still in progress. And now the second test
has also completed successfully. Now let’s accelerate things even more by
running both tests at the same time. To do that, we’ll install a utility for running
our tests in parallel, then run the tests again. We’ll switch back to the dashboard, where
we can see that Sauce Labs has started two concurrent virtual machines for the tests,
and both tests are executing in parallel. Parallel test execution is the secret Sauce
for supercharging your development process, and creating a robust CI/CD pipeline. Instead of waiting for each test to complete
one after the other, you can run dozens, hundreds or even thousands of tests at the same time,
and your total test execution time will only take as long as your longest individual test. Now that our tests are complete, we can click
a test’s name to access its results. We can watch a video recording of the entire
test – which is very helpful for diagnosing test anomalies, we can also view every command
that was executed as part of the test, including screen shots of any command that
modifies the appearance of the browser. View selenium server logs, and
view all the test’s metadata. The metadata tab is also where we can download
copies of screenshots and video captures. Because we enable extended debugging and Sauce
Performance, we also have access to data in the “Network” and “Performance” tabs. The “Network” tab shows front-end webpage
performance data, so we can predict how our end users will experience our website. We can see all the page assets that were loaded,
and how long each asset took to load. And all this information is captured in an HTTP
Archive file, which we can download for later analysis The performance tab provides visual analysis
of page performance metrics, including an overall performance score, and other data
like first contentful paint, time to interactive, first meaningful paint and other key
performance indicators that that directly impact your end users’ performance. Another capability unique to Sauce Labs is
the ability to organize groups of tests into builds, which is very useful for teams and
integration into CI/CD workflows. We’ll add the “build” parameter to our
SauceOptions, then run our tests again. The tests execute as normal and show up in
the automated tests tab, but we also get a build running in the Automated Builds tab. We can click the build to see all the tests
running under that build name, and very quickly review the
history of each test in the build. We can also see the build results in the Sauce
Labs dashboard, which is another helpful indicator of our overall execution health. The build passed because all our tests passed,
but if one of our tests had failed, the build would have failed too, and we could have quickly
drilled down into the build to evaluate the individual test results. Running automated web tests on the Sauce Labs
Continuous Testing cloud is fast and easy, and enables you to run your tests faster,
more frequently, and with more reliable results. Sign up for a free trial today, and start
enjoying the digital confidence that you’re always delivering the best possible
user experience to your customers.

Leave a Reply

Your email address will not be published. Required fields are marked *