Katalon Studio vs Selenium what should I learn


#1

I had seen this FAQ “Katalon Studio vs Selenium” from beginners wondering what to learn first, so I’ve created a sample project to show how to write vanilla Selenium code in Katalon Studio.

Selenium is one of the building blocks of Katalon Studio, so while we provide convenient features like Test Case / Test Suite management, Test Object, built-in WebDriver, Custom Keywords, integration, etc., we do not prevent users from writing vanilla Selenium code. You can even start learning Selenium using Katalon Studio to minimize the environment setup efforts and focus on XPath, programming, test design, and integration. If you are about to start your venture into Selenium, be confident that Katalon Studio and this community will be your good friends :wink:.

I also hope other competitors would stop branding us as a codeless-only automation solution, since this is obviously not true.

The scenario for sample test cases is to go to Google and search for “Katalon Studio”.

Selenium

This test case uses Selenium as we knew it.

driver.get("http://www.google.com")
WebElement element = driver.findElement(By.name("q"))
element.sendKeys("Katalon Studio")
element.submit()

To achieve the same thing using Katalon Studio’s keywords, see the test case Katalon:

WebUI.navigateToUrl("http://www.google.com")
WebUI.sendKeys(findTestObject('Object Repository/SearchBox'), "Katalon Studio")
WebUI.submit(findTestObject('Object Repository/SearchBox'))

Now, let’s make these test cases more maintainable with the Page Object Model (POM) pattern.

Selenium with Page Object Model

In this test case, I refactored the above code into Selenium’s implementation of POM.

driver.get("http://www.google.com/")
GoogleSearchPage page = PageFactory.initElements(driver, GoogleSearchPage.class)
page.searchFor("Katalon Studio")
public class GoogleSearchPage {

	@FindBy(how = How.NAME, using = "q")
	private WebElement searchBox

	public void searchFor(String text) {
		searchBox.sendKeys(text)
		searchBox.submit()
	}
}

The test case KatalonWithPageObjectModel shows how to do it the Katalon Studio way.

WebUI.navigateToUrl('http://www.google.com')
CustomKeywords.'test.KatalonGoogleSearchPage.searchFor'('Katalon Studio')
class KatalonGoogleSearchPage {

	@Keyword
	def searchFor(String word) {
		WebUI.sendKeys(findTestObject('Object Repository/SearchBox'), word)
		WebUI.submit(findTestObject('Object Repository/SearchBox'))
	}
}

One nice thing here is that Katalon Studio’s keywords help ease the collaboration between coding-centric teams and UAT-centric teams (manual QA, BA)

Bonus: Selenide

This test case demonstrates the capability to integrate Katalon Studio with other Selenium-based libraries. Selenide is a library with concise fluent API for working with Selenium’s WebElement. As our mission is to provide a free and robust test automation solution for the software testing community, we strongly believe in an open ecosystem where users can utilize any frameworks or libraries for their test projects. In short, no vendor-locking here.

Selenide.open("https://www.google.com")
Selenide.$(By.name("q")).val("Katalon Studio").pressEnter()

Bonus: Geb

Geb is yet another Selenium-based framework. Its scripts are written in Groovy.

Browser.drive(browser) {
	go "https://www.google.com"
	$("[name=q]") << "Katalon Studio"
	$("[name=q]") << Keys.ENTER
}

Like other frameworks, Geb has its own take of Page Object Model.

Browser.drive(browser) {
	to GebGoogleSearchPage
	searchFor("Katalon Studio")
}
public class GebGoogleSearchPage extends Page {
	
    static url = "https://www.google.com"
	
    static content = {
        searchField { $("[name=q]") }
    }

    void searchFor(String text) {
		searchField << text
        searchField << Keys.ENTER
    }
}

Why Katalon Studio?

Whatever frameworks/libraries you use, you will always have Katalon Studio’s convenient features I mentioned, out-of-the-box:


Katalon Studio vs Selenium