This document expresses about the Testcafe’s strength and implementation for an E2E web testing based on the analysis done by our QA team. And of course, let’s discuss the similarities and dissimilarities between webdriver and Testcafe’s testing framework.

What is End-End Testing?

E2e testing is where validation has been carried out for the entire application end-to-end by simulating as an end user.
Before, knowing how the Testcafe core has been implemented without selenium webdriver, let us understand few things about selenium webdriver and what it is lacking to compete in the race in the modern web technology testing tools.

Few things about Selenium,

  • Selenium Webdriver is become conventional and dominating core automation library for the web-based applications.
  • It supports the major market browsers (IE, Chrome, Firefox, Safari, Opera.,) with the help of respective proprietary browser driver engine.
  • It is supported in different language flavours (Java, JS, Python, Php, Ruby, C#.,) because selenium webdriver browser commands are sent to the browser using the HTTP protocol.
  • It has a huge community support.
  • WebDriver API has evolved in many ways and has nice support for most of the browser-based actions.

However, more than a decade, Selenium webdriver commanding the automation industry. Still, features like Internal wait mechanism, Remote browser execution, front-end framework specific APIs, compatible releases between versions are not available in the Selenium Webdriver version 3.x.

So, What the next?

Here comes the Testcafe to protect us from writing an extensive amount of code and configs to set up the test environment and instead it would allow us to concentrate more on the validation part. Let’s start to discuss the tool-Testcafe which would reform the drawbacks in the selenium webdriver API.

Fundamentally, TestCafe an open-source(MIT License) node.js tool to automate end-to-end web testing.

TestcafeFeatures
Fig1- Features of Testcafe

Game-changing Features in Testcafe:

Simplified setup – All you need is to install the TestCafe’s core npm package and directly start writing the tests including high-level assertions.

URL-rewriting proxy- There is a powerful web-proxy(testcafe-hammerhead) like a middleman which resides between your application server and the browser. This web-proxy rewrites all properties of the appropriate JavaScript objects that contain a URL value. And it helps us to simulate user action in the AUT and can do anything with your AUT.

urlRewrittingproxy
Fig1.1- Depicts the working of Url rewritting proxy

Test Runs on across platform-

  • Browser support – though it uses the Url-rewriting web proxy, the supported browsers are limited due to testing of the testcafe’s solution against those browsers.
  • You can find the officially supported browser here.
  • Testcafe allows you to run your tests in remote and mobile browsers. To achieve this always assure that the testcafe server(testcafe installed environment) and mobile browser(Android chrome browser) receive the same network.
  • Delightfully, they support testing your application in cloud-based services(SauceLabs, BrowserStack) by using browser provider plugins.

Auto wait mechanism- Synchronization(between the app and test code) is always a nightmare for the automation testers. And we always struggle to achieve better sync, flakiness free tests by employing some sort of waiting mechanism provided by the Automation API. This approach is not always a promising solution.
    To overcome the above-said problem, Testcafe shipped with “InBuilt wait mechanism” which uses “Smart Assertion Query Mechanism“.  This built-in wait mechanism does not need any dedicated API to wait for Elements/Assertion/Test actions explicitly. Additionaly , One can override the default timeout values using the command line or runner task.

Rapid test development- TestCafe-Live will help us to modify our test on the fly which preserves the test script creation effort.

Easy concurrent execution- It’s obvious that an e2e testing framework must be capable of running test in side-by-side and distributed mode. These sort of concurrent testing is introduced to reduce the execution time and to accomplish the cross-browser testing.In this context, Testcafe supports running your test in concurrent mode through command line and API.

Framework specified selectors- Apart from a full-fledged general selector support,  they developed and provide support for modern web development framework(React, Vue, AngularJS) selectors.

         For Eg; ReactJs – framework – This ability provides selector extensions that make it easier to test ReactJS components with TestCafe. These extensions allow you to select page elements in a way that is native to React.

To wait until the React’s component tree is loaded, add the waitForReact method to fixture’s beforeEach hook.

 

 

Extending TestCafe- Extending and including new functionality to the test-automation framework needs a considerable amount of time investment and Of course, technical expertise.

So, To avoid wasting huge effort upon extending the framework, testcafe provides a lot of plugins and extension for Reporting, Browser Providers, etc.  What if you don’t find any plugin which would resolve/help to extend your framework? Just create one using their low-level plugin generating APIs.

Other Notable Features:

  1. Optionally, it comes with cross-platform IDE, which could record and playback test scripts. So, less code more validations.
  2. Docker image provided by Testcafe comes with pre-installed chromium and firefox.
  3. It supports the integration with task runners like Grunt and Gulp.
  4. Finding Code Issues with Flow Type Checker.
  5. Handles HTTP request/response without including any 3rd party libraries and can create custom HTTP request hooks.

Conclusion:

Like Selenium Webdriver,
Testcafe should extend their support towards other major languages like Java, Python.
Apart from language support, Testcafe is Unquestionably worth giving a try.