Page Object Model

Is there any way to implement page object model in katalon studio? Please help

anyone there pls help me on this

POM is an idea separating each WebPage into smaller PageObject for maintainence purpose. In stead of making each WebPage a separated Class (ie implemeted in Java, etc), in Katalon Studio, we use the same approach with a little bit different implementation: Object Repository and Test Case.

Hence, there are 2 options we could use to implement POM:
- Use script mode completely. In this mode (at Keywords section), we can create PageObject classes (groovy/java) the same as implementation of any testing frameworks
- Use Katalon manual mode to create a structure as following image. PageObject is splitted at 2 area: Object Repository and Test Cases. The “call TestCase” function is used to reuse/call methods built in each page.



We implement “page object Model” or Page object Pattern by identifying first the pages… calling them: Page_Login,Page_Home,Page_ContactUs, etc . Within those pages are the objects defined in the object repository(this is ok to have the object once and not duplication of the object).
In the Keywords section we have Page_Login class with all the necessary methods to log to the application…implemented as @keyword (example : login keyword , so in all tests that needs to login…we call only one keyword by passing por example user and password). So we have each page has it own class keywords like selenium does.


Here is an example on how i implemented:


I tried to implement the POM model in Katalon, and used it with BDD tests.
I’ve got an issue in the “loginSteps.groovy” file, with the customkeyword “login(String Username, String Password)”. Indeed, the test failed to enter in this step.
I tried to bypasse customkeyword and write directly every login step in the “loginSteps.groovy”, and it worked.
So I guessed I’ve got an issue with my login customkeyword.

Any recommandation or advice ?

which error were you getting ?

Hi Francorebu,

Please find below the error log.

Thanks for your help.

2019-12-09 13:34:45.385 ERROR c.k.k.core.main.WSVerificationExecutor - :x: Verification FAILED.
com.kms.katalon.core.exception.StepFailedException: Feature file ‘Include/features/login.feature’ was failed
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:50)
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:23)
at com.kms.katalon.core.keyword.internal.KeywordMain$stepFailed$ Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$_runFeatureFile_closure1.doCall(CucumberBuiltinKeywords.groovy:82)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$_runFeatureFile_closure1.doCall(CucumberBuiltinKeywords.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordMain$ Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:46)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile$0.callStatic(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:169)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$ Source)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(
at com.kms.katalon.core.main.WSVerificationExecutor.runScript(
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(
at com.kms.katalon.core.main.WSVerificationExecutor.execute(
at com.kms.katalon.core.main.TestCaseMain.runFeatureFile(
at com.kms.katalon.core.main.TestCaseMain$runFeatureFile$ Source)

It happens that you are calling a keyword from a stepdephinition, in the same way that you are calling the keyword only used for test cases, to call a keyword from a step you must instantiate the class and access the word key through the object or on the contrary declare the static method to access without instantiating.
best regards

Hi, thanks for the answer.
Problem solved.
In fact, I found my mistake.
I tried to pass a “test object” as an argument rather than a string for my custom keyword.

Hello, I would like to know how you have implemented the stepsdephinitions in that same case.
On the other hand knowing if you use data through an excel with that same model and if that is how it would be, I would appreciate

Hi francorebu. Could you please show how you are using this class in your tests? Thanks.

Yes sure. You can see line 18 (the one that is highlighted) . You can see another methods (keywords) from the other pages as well.


Well, im not working with Katalon right now but I remember how i used excel files. As you know a test case can have one or more variables that could be the input data for that cases So after creating the variables, then you have to create a datafile (to store the information )one or more rows with same columns names as the testcase has . so , when you put that parameterized test case in a testsuite, you can bind the datafile(excel or csv) to the testcase so the testcase will iterate as manny rows the file has. I think that you can specify the range of rows you want to execute as well. Im not so familiar with bdd but once you have the methods with bdd you can write the escenario and you are going to call the predefined methods that you have so you can reuse those methods.

Thank you, francorebu!

1 Like

Hi francorebu.
Do you happen to know whether or not a code like yours would be working if a web page corresponding to the POM gets refreshed?

What I mean is, in your code for the POM, findTestObject() is used to initialize the elements. I’m not sure how it works but I can imagine something like this: it finds an element on the web page and returns some kind of reference to it. If the page gets refreshed, that reference might not be valid anymore.

Also, do you happen to know whether for every call of keyword (as in your screenshot) a new object of the keyword is created? Or an object for the keyword is created only once? Thanks.

Also, could you please reply to my post above? Thanks. The post above was supposed to be reply to your post with the screenshot but by mistake I “replied” to my reply to your original post. I was trying to reply to your original post again but it didn’t allow me to post 3 posts in the row.

This was perfect! Thanks so much.