“Have fun” with Selenium: Developer v Tester

Tram Ho

Introduction

Selenium is known as the most powerful and most common automation test framework available today. The power of Selenium is so great that from a tool for testers, it has infiltrated the world of developers, the archenemy of testers. Yes, with the help of Capybara and Cucumber, writing system tests is no longer too difficult. Thanks to the ability to control a browser like a real person, developers also use Selenium for some other automated tasks, typically web crawling. This puts Selenium in an interesting position, developers and testers each see and use it in different ways, and the byproducts create completely different.

This article hopes to provide a different perspective on using Selenium to bring the most comfort and convenience to both sides: Developer and Tester.

1. The starter kit

To be able to compare how we do it, we start with a most basic example: Test the login function screen. Here I have a demo of the login page of CoreUI ( https://coreui.io/demo/3.2.0/login.html )

Selenium and Ruby developer

For the mental health of both readers and writers, I would like to present the code using Capybara (selenium driver is still used of course). The installation and setting stages are also ignored, because at the time of writing, Google has yet to charge? And after skipping most of the work, we’ll have a piece of code like this:

Selenium and Tester

Please note that the writer is not a tester, so the knowledge in this section is naïve and may have been outdated Monkey see, Monkey do. We can install the Chrome extension Selenium IDE and easily solve the problem.

2. The crossroad

We can see a simple problem but each side has come up with a different solution, and doesn’t even seem to be related in terms of technical structure, despite being built on the same communication. The question here is whether we can combine both solutions to take advantage of both. A common solution is to build a separate system for testers running Selenium, but this system is often inaccessible for developers, or vice versa, the developers will read the script files on the IDE, then translate again according to the language. programming their own, this is quite time consuming and is usually only possible with test cases that are not too complex or bulky.

Fortunately, the developers of Selenium have seen this and introduced us to the selenium-side-runner tool. All we have to do is export the test case to a .side file, run the file, and check the results.

Install selenium-side-runner and run the script and read the result:

Easy life!

3. Let’s mix it up together, and crank it up to eleven!

Because the above method seems so easy, and as a developer, you have to make things seem more complicated, to match the effort of testers who have spent writing test scripts, or for some reason. Heaven somehow makes it possible to install selenium-side-runner on the machine, not to mention running shell script in code also brings many unpredictable side effects, it’s okay, this article will provide you with a solution. step one:

  1. Download the Selenium IDE extension file and install it on Chromedriver. We can do the same as the instructions here

  1. Open Selenium IDE and run the test script file

  1. Check the results on the Selenium IDE output log

The idea here is that instead of using Capybara to simulate human actions, we use it to simulate testers’ actions, which is to open the test script file and run, while the testers will be responsible. in the processing of simulated human actions in test cases.

Epilogue

With Agile programming models evolving, it is not too strange for a tester to know code or a Developer to grasp tesing techniques. Finding and developing tools to neutralize the views of these two positions is no longer too early or too impractical. The writer himself has no intention of exploring or paving the way at all, it all starts with the discovery and testing of possibilities. And finally, according to the title of the post, just have some fun.

Share the news now

Source : Viblo