Selenium Vs Katalon Studio: How to Simplify Selenium Tests in Katalon Studio

Selenium Vs Katalon Studio – Learn the Ways to Simplify Selenium Tests in Katalon Studio (with a login test case hands-on example on both the tools)

Automated testing is a technique that uses an application to conduct the testing process for another application.

For Web-based software, automated testing is important and is widely used as it allows cost-effective UI testing, which is crucial to maintain high-quality services.

Selenium is one of the most popular open-source automation tools for Web automation testing. You can do a lot with Selenium, such as refactoring web elements into classes that can be reused easily in your test cases, etc.

Katalon Vs Selenium

However, if you are new to test automation, then these complex features might not be suitable for your testing needs. There might be chances that you don't want to concern yourself with such feasts yet, and you want to write tests immediately and pick up such design principles along the way.

In such a case, Katalon Studio would be a better fit.

This tutorial is a gentle introduction to automation testing using Selenium and Katalon Studio tools.

In the first part, you will automate a login use case with Selenium which is a Web testing framework and in the second part, you will learn how to do the same task with much lesser effort using Katalon Studio.

Suggested Reading =>Read our previous Katalon Studio detailed tutorial here

Selenium Vs Katalon Studio

Features of Selenium and Katalon Studio

How to Write Automated Tests using Selenium

Selenium is an open-source tool that automates Web browsers. It provides a single interface that will allow you to write test scripts in programming languages like Ruby, Java, NodeJS, PHP, Perl, Python, and C#, among others.

Selenium also allows great flexibility for you to transfer all programming experiences to software testing, and this will be demonstrated later.

In this part, you will learn how to:

  • Create a Maven project in Eclipse
  • Install Selenium
  • Log into LinkedIn using Selenium

Here are the prerequisites that you’ll need:

  • An OS with Java installed in it.
  • Eclipse IDE. (or a Java-compatible IDE that also supports Maven)
  • ChromeDriver

How to Create a Maven Project in Eclipse

A Maven project in Eclipse gives you the benefit of specifying all the libraries that you need in a file. These libraries will be automatically downloaded and used.

To start, open Eclipse with your chosen workspace, and then follow the below steps:

  1. Right-click in any place under the Package Explorer tab.
  2. Choose New => Other and a New window will appear.
  3. In the search box, type in “Maven” and select the Maven Project.
  4. Click Next for all panels until you reach the Specify Archetype parameters step.
  5. In the Specify Archetype parameters step, provide your inputs.
  6. Click Finish.

That's it !. You now have a Maven project. The most important files are App.java and pom.xml – the main class for your application and the file where you declare your libraries respectively.

Click here to learn more about creating a Maven project.

How to Install Selenium

Maven project has been created and you can easily install Selenium just by copy, pasting the following codes.

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>

into pom.xml between the <dependencies></dependencies>. Your pom.xml file should look like as shown below.

pom.xml file

Hit Save and then wait for the Eclipse to download your dependencies. Now you can start using Selenium in your code.

How to Log into LinkedIn using Selenium

Copy and paste the following code into the main function of your App.java

System.setProperty("webdriver.chrome.driver","pathToChromeDriver");
WebDriver driver = new ChromeDriver();
driver.get("https://www.linkedin.com/");

WebElement inputUsername = driver.findElement(By.xpath("//input[@id='login-email']"));
inputUsername.sendKeys("yourLinkedinUsername");

WebElement inputPassword = driver.findElement(By.xpath("//input[@id='login-password']"));
inputPassword.sendKeys("yourLinkedInPassword");

WebElement btnLogIn = driver.findElement(By.xpath("//input[@id='login-submit']"));
btnLogIn.click(); 

The above code uses XPath to locate the target web elements, which in this case are the inputs for username, password, and the login button.

Run your application and you will see your browser opening up, navigate to LinkedIn and log into your account.

How to Write Automated Tests using Katalon Studio

This part will guide you through achieving the same results above with much lesser effort in Katalon Studio.

Katalon Studio is an automated testing solution that covers Web, API, and mobile testing. What makes Katalon Studio user-friendly is that it enables testers to write robust automated test cases with and without code, and thanks to its designed IDE.

The tool also includes pre-defined artifact templates such as test case, test suite, and test suite collection so that test management becomes easier than ever.

Katalon Studio provides you with Selenium functionalities, ChromeDriver, and a scripting interface, all of which are available in one application. Therefore there is no need to set up anything. Simply open Katalon Studio to start developing the tests.

We'll show you how to:

  • Create a Web Testing project in Katalon Studio.
  • How to use the Web Recorder.

Given are the only two prerequisites that you'll need:

How to Create a Web Testing Project in Katalon Studio

First, create a new project.

create a new project.

Open Katalon Studio. Choose Web for project type and click OK.

Choose Web for project type in Katalon

How to Use Web Recorder

Once a Web Project has been created, you can initiate the Web Recorder feature by clicking on the icon as shown below.

Initiate Web Recorder feature

Select the Chrome browser and start recording.

select Chrome browser and start recording.

The Chrome browser will open up and navigate to linkedin.com. All your interactions within this browser are recorded in real-time so that you can just log-in to your account as you would normally do and the Web Recorder will show the corresponding steps.

Navigated to linkedin.com

After you have finished recording your test case, hit OK and then save your test case and test objects. To run this test case, click the Play icon as shown in the below image.

Click the Play icon to Run the Test Case

Your interactions will be played back in the way in which they were recorded. This is how you write a test case in Katalon Studio.

Conclusion

From this tutorial, we have learned, how to do basic automation testing with Selenium and Katalon Studio.

In Katalon Studio, test objects are organized according to the Page-Object Model which promote reusability across multiple test cases. Interactions with websites can be captured via Web Recorder in order to serve as boilerplates for more complex test scenarios.

If you are new to test automation, then we would recommend you to start with the best practices in Katalon Studio instead of jumping right away to Selenium because of its steep learning curve.

Once you become more proficient, you will see the need to use programming for further empowerment of your automation tests. Later, you can use all the Selenium functionalities in Katalon Studio via the provided scripting interface that supports Java and Groovy.

However, if you are already a programming expert or if you don't want to learn a new language, then Selenium would be a better fit as its APIs are implemented in multiple programming languages such as C#, Ruby, Perl, Python, R, and so on.

Start automating by downloading Katalon Studio from here! Feel free to share your experiences with us in the comments section below!

Recommended Reading

2 thoughts on “Selenium Vs Katalon Studio: How to Simplify Selenium Tests in Katalon Studio”

  1. I missed this webinar, but I think it would be a great resource for some of the volunteers we are working with .Is there any time that this webinar will be offered again, or is there any way for me to get a copy of the slides?

Leave a Comment