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.
Table of Contents:
Selenium Vs Katalon Studio
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.
As such, 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 less effort using Katalon Studio.
Suggested Reading =>Read our previous Katalon Studio detailed tutorial here
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 in to LinkedIn using Selenium
Here are the prerequisites that you’ll need:
- 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 the Eclipse with your chosen workspace, and then follow the steps below:
- Right-click anywhere under the Package Explorer tab.
- Choose New => Other and a New window will appear.
- In the search box, type in “Maven” and select the Maven Project.
- Click Next for all panels until you reach the Specify Archetype parameters step.
- In the Specify Archetype parameters step, provide your inputs.
- 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 copying and 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 as shown below.
Hit Save and then wait for the Eclipse to download your dependencies. You can now start using Selenium in your code.
How to Log in to 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 as above with much less 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, thanks to its designed IDE.
The tool also includes pre-defined artifact templates such as test cases, test suites, and test suite collections 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 anything up. 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:
- Katalon Studio (download here)
- Chrome browser
How to Create a Web Testing Project in Katalon Studio
First, create a new project.
Open Katalon Studio. Choose Web for project type and click OK.
How to Use a Web Recorder
Once a Web Project has been created, you can initiate the Web Recorder feature by clicking on the icon as shown below.
Select the Chrome browser and start recording.
Open a Chrome browser that will open up and navigate to linkedin.com. All your interactions within this browser are recorded in real-time so you can just log in to your account as you would normally do and the Web Recorder will show the corresponding steps.
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 on the Play icon as shown in the image below.
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 promotes 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 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!
Katalon is suitable for small-sized projects.
We invested a lot of time in migrating our scripts from protractor to katalon and later we ended up with huge maintenance, no reusability as our test data in Huge.
And later looking into all blogs on katalon, I got no support for my issues from katalon and no proper documentation(it is unable to execute complex jquery as other tools do)
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?
Katalon Studio (free edition) from v7 has most of the useful features removed. They have been migrated to Katalon Studio Enterprise ($760/yr) + Katalon Runtime Engine ($569/yr).
They are *killing* V6 at the end of April – it won’t install or activate after then.
I wish I had known this solution sooner. Katalon Studio is really working well. Thanks for sharing!
Thanks for sharing great article.