How to Successfully Automate Your Cross-Browser Tests
  March 03, 2020

Testing your software or application before releasing it into the wild isn't just a nice-to-have. Developers and QA teams spend hours making sure their company releases high-quality products. However, testing practices and requirements for web apps have changed in recent years, and new complexities require efficient solutions, such as test automation. So let's talk more about automating your cross-browser tests, what to automate and what not, and which tools are best suited for the job.

What is test automation, and how can you benefit from it?

When Internet Explorer 6 was the most common browser, hardly anyone used Google Chrome, smartphones, or tablets. Developers only had a few browsers of which they had to test their website on, and there was usually nothing more to do – testing was not as demanding as it is now. Also, the products built back then weren't as sophisticated as what you can find online today. E-commerce sites, online banking, complicated UI structures, and animations with CSS required developers to step up their testing game. Add all the different smartphones, tablets, different browsers, and their versions into the mix, and you can see, cross-browser testing is much more critical these days.

If our testing practices looked the same as they did in the IE 6 era, we would likely publish bug-infested web apps that most people wouldn't even look at. Of course, by now, we all know how necessary thorough testing is and that we need to run various types of tests (e.g., functional tests, performance tests, security tests, etc.) to ensure that our app works and looks perfectly. Yet, testing can be time-consuming – the more tests you need to run, the longer it will take to release your app. And that's where test automation comes in to save the day.

Test automation helps you save time by letting developers configure test cases and have them run automatically by a tool. If you're cross-browser testing, instead of manually interacting with your web application, you can prepare a script, define and configure the browsers you want to test, and then have a browser automation tool do everything for you.

However, saving time isn't the only benefit you can enjoy from automating your cross-browser tests! Read on to discover more.

Know what to automate and what not

You have probably heard that manual testing leads to bottlenecks, worsens time-to-market, and possibly bores your test teams out of their minds. At the moment, though, we can hardly execute 100% of our tests automatically (although that would be nice). For example, User Experience testing requires a human tester, other tests may be completed faster manually, etc.

Regardless of which tools you use for cross-browser testing, you and your team must define what should and should not be automated, to be able to achieve the desired results efficiently.

In general, these types of tests can be automated:

  • Tests that you expect to get a specific result, e.g., unit testing
  • Repetitive tests that have to be carried out frequently, e.g., login (authentication)
  • Tests that you have to run with different options and parameters, e.g., a contact form with mandatory fields, email address verification, etc.

Yet, manual testing can be a better choice for:

  • Tests that get flaky due to automation. For example, if your test has to wait for input from a third-party source that doesn't always deliver on time and therefore can't produce consistent results, you'd be better off running the test manually.
  • Tests that are too complicated or computationally intensive, but can be carried out quickly by a human.
  • Everything that protects your web app or itself from automation, such as captchas. It would make no sense if you could test and pass a captcha automatically, right?
  • Tests based on a user's subjective opinion, such as UX tests and any other types of analysis that goes more in the look-and-feel direction of your app.

After talking about what can be automated, we need to talk about which tool to use. One of the most popular and useful frameworks for cross-browser test automation is Selenium – let's find out what it is and how it can help you.

Use Selenium to automate your cross-browser tests

Selenium is a robust framework that consists of various tools and was initially developed by Jason Huggins in 2004. Allegedly, the name comes from one of his emails, in which he made fun of a competitor named Mercury by writing that selenium mineral supplements can cure mercury poisoning.

The part of the framework we're most interested in now is Selenium WebDriver, which is used to automate cross-browser testing. WebDriver accepts commands and sends them to a browser to execute them (hence the name). Teams can automate tests for their web applications by instructing WebDriver to perform specific actions in any browser and device. It's also worth noting that the WebDriver specification made it into the W3C recommendations in June 2018, further increasing the tool's popularity.

Selenium helps you and your team save valuable time that you can spend on other tasks that still require a human’s full attention, such as analyzing test results and performing manual tests. However, before you blindly start automating your test cases with Selenium, you need to determine which tests can and cannot be automated. To do this, you can use our lists from above to get started. If you want to learn more about test automation with Selenium, be sure to check out our Selenium Toolkit!

Run your automated tests in parallel

Automating your Selenium tests is an essential step in improving test execution times, but you can do more! The real magic unfolds when you run your automated tests in parallel on multiple browsers and/or devices. Let's say a test case takes about 10 minutes to execute, and you need to test 10 different browsers and devices. If you check one browser and device combo at a time, it will take about 100 minutes to finish. However, if you run the script in all required environments at once, you'll be finished in about 10 minutes!

Parallel tests enable you to test your web app on more devices and browsers in the shortest possible time. For this, you can use Selenium Grid, which allows you to execute your Selenium tests on multiple environments at once. But, the right infrastructure is required for Selenium Grid because it is based on a hub-node concept. This means that you need one machine – the hub – to host the tests, and several machines – the nodes – to execute tests on different browsers, browser versions, etc.

Make sure you have the resources to set up and maintain the necessary infrastructure if you want to run Selenium Grid on-premises. If you don’t want to manage the infrastructure yourself and have additional requirements, e.g., running your tests on real devices as opposed to simulators, you can try a web-based test service.

Conclusion

Selenium is the best choice if you want to automate your cross-browser tests and make them future-proof. Before you start automating, however, you should spend some time thinking about your product and its features to find out what you can and should automate, and what needs to be tested manually.

Make sure you run your automated tests in parallel for the best possible efficiency. Run hundreds of tests in parallel on thousands of real desktop and mobile browsers with our optimized test infrastructure in the cloud. Start your free trial and take advantage of executing your automated tests in parallel on real devices and browsers.