Why Test Café?
Automation testers mostly opt for Selenium, when it comes to automating the testing of web applications. Selenium being an open-source tool and its support for many programming languages and browsers, make it a widely accepted automation tool among the testers. But those who have worked with Selenium are aware of the many challenges in it, like having to manage different types of wait, the need to install drivers for browser support, the need to match the driver and browser versions to avoid compatibility issues, etc. Test Café is a solution for all these challenges.
Features of Test Café
How to setup Test Café?
Before installing Test Café, you should have Node.js and Node Package Manager (npm) installed in your system. These are the pre-requisites for Test Café. So, first we will install Node.js and npm. There are many ways to do this. Here, we will see how to install nvm-for-windows (node version manager – windows) first and then how we can use it to install Node.js and npm.
Steps to install nvm-for-windows
Now, we have nvm-for-windows successfully installed in our machine.
Steps to install Node.js and npm
Now you should be able to see the folder “nodejs” in the chosen directory (here, it is C:\Program Files)
By now, Node.js and npm should be successfully installed in your machine. You can verify this, using the following commands:
Now, the 2 pre-requisites of Test Café are available in your system. Before installing Test Café, we can install an IDE first.
Just like we use Eclipse or IntelliJ IDE for developing Selenium tests, we need an IDE for developing test café tests also. You can choose any IDE of your choice. If you prefer using Visual Studio Code, you can download it from https://code.visualstudio.com/download.
From here, you can select the option that suits your environment. The setup file will get downloaded to your machine. It will just take a minute to complete the installation.
Now, we are ready to install Test Café.
Install Test Café
We can install Test Café in 3 ways – Global Installation, Local Installation, Ad hoc Installation.
In this article, we will see how Test Café can be installed via Global Installation. It is a very simple 1 step process. You can install Test Café from npm using the command: npm install -g testcafe
That’s it!! Test Café is installed.
How to run Test Café tests?
To run the tests in Chrome browser, you can use the command: testcafe chrome tests/
This error is expected, as we haven’t created any test file.
For this command to execute properly, there should be test files under “tests” folder. If you need to execute only a single test, provide the file directly in this command. If you need to test the scenario in another browser, replace Chrome with that browser name in the command (for example, give the command as: testcafe firefox tests/). To run the tests in headless mode, use the keyword headless (example, testcafe chrome: headless tests/)
How to create and execute a Test Café test?
In our example test, I will load https://www.pitsolutions.ch/, navigate to Contact page and assert the presence of “OFFER ENQUIRY” button in the page.
Test Café Code Structure
Test Execution in Chrome browser
The following image shows the same test executed in Firefox browser. Once the test run is complete, we will see the result like this. We can see the browser info – in which browser and OS, the test was executed, the test result (Pass/Fail), and the test execution time.
Test Café seems like a promising web automation tool, which can be used for end-to-end testing. Installation is simple and your first test would be running in about a few minutes. Test Café doesn’t require any external plugins to run tests on different browsers. Almost all the features provided by Selenium are available in Test Café too. Moreover, it solves the challenges that come with Selenium.
Test Café is indeed worth giving a try!