Second of the Trilogy: Automated Testing of Web Apps
Credit/Source: Katalon LLC & Katalon Studio

Second of the Trilogy: Automated Testing of Web Apps

Following the first article, we'll be continuing our journey on the quest of Katalon Studio - a powerful, yet, simple tool for automated testing. This article will cover testing for one of the most common features of modern web app - authentication.

We already covered setting up of Katalon Studio; you can refer to this doc, if needed. To get started, navigate to this website which is our favorite mock website. Lets create a test case for user login and add it to already created project "DemoSiteProject". From Katalon Studio, File-->New-->Test case to create our test case and lets name this test case "DemoSite-Login".

Figure: Test case steps and commands for DemoSite_Login

  1. Click on "DemoSite-Login" test case and click on the "Web Recorder" icon (this is the icon with a red recording button over a www globe). This will open up the Web Recorder window and you can enter this URL: "https://thedemosite.co.uk/". We will be using Google Chrome as the choice of browser so from the drop-down besides the URL field, select/click Google Chrome.
  2. This action will initiate the automated recorder session and you will be navigated to that demo website. At the top of this website, you'll find these sections: 1. Home | 2. The Database | 3. Add a User | 4. Login | 5. Get your db online . Click on "4. Login".
  3. Optional: From previous, if you already created "superman/kryptoni" username/password combination; you can use that. If not, feel free to use 3. Add a User to add a user first.
  4. On the Login page, enter the username under "Username:" field and password in the subsequent field. Click on "Test Login" button and this should show a "**Successful Login**" message.
  5. That's it on the Web Recorder! On the Web Recorder, click on the stop button and then click "Ok". Katalon Web Recorder will ask you to save the web objects you captured for this session. Its a good practice to create a separate object repository for each test case. For more info on Katalon Studio objects, refer to this link. Now you should see Katalon Studio populate your test case "DemoSite_Login" with a bunch of commands. If you inspect closely, these commands are just the reflection of the actions you performed just now and we need to tweak them slightly to finalize our test case.
  6. Considering that you are under "Manual" tab where you are seeing all the commands; first change we need to make is from "Set Encrypted Text" (Item#5 or Item#6) to "Set Text" (to change, simply double-click on the command and type in the desired command. Feel free to take advantage of auto-complete feature to find out available commands). We don't have a verification command for our test case (kinda the main piece) so lets add that piece! Before Item#10 (or Item#9) "Close Browser", add this command "Verify Text Present". The purpose of this command is to ensure that we verify a confirmation message appeared after going through a particular test case scenario. After we hit "Test Login" button, you were displayed the login success message of "**Successful Login**". We will be using this text as a verification text for our test case. Back to Katalon Studio, in the "Input" column for "Verify Text Present command, double-click and enter the value for the text field as "**Successful Login**" (leave the isRegex field as-is). Once done, your completed test case should look like the above screenshot (you can ignore Item#3 and Item#8 for now).
  7. That's it! Hold your breath and hit the Run button from the top-right corner of the tool. A successful run looks something like this (observe "Passes: 1" in the Log Viewer section) :

Trouble-shooting:

  • If your test case fails, refer to the Log Viewer for further details. If it complains about not finding the expected text (which is "**Successful Login**" in our case), remove all the commands and restart the Web Recorder. This time, after hitting 'Test Login' button, click within the area of the section "**Successful Login**". This action will product Item#8. Basically here we are telling Katalon Studio where to look for the verification text.
  • Its a good practice to use variables for various parameters such as URL, username, password etc. Defining and using variables are pretty straight-forward and you can refer to this link (under "Local Variables") for further details.
  • In actual projects, you'd not need to create a user on the fly for testing login. Rather, you'd be using the database to use an existing username/password combination.
You don't have to hold your breath anymore
Jeremy Seal

Head of Sales & GTM Strategy @ CoachHub | Revenue Operations | Sales & Strategy | MBA

6 年

Keep it up! I love the knowledge share. Great job leveraging different testing assets to build a testing procedure & structure that will result in a quality product for our client!

要查看或添加评论,请登录

社区洞察

其他会员也浏览了