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.

image.png

5 Likes

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.

5 Likes

Here is an example on how i implemented:

5 Likes

Hi,
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 ?
Thanks
Fred

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.
Reason:
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$0.call(Unknown 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$runKeyword.call(Unknown 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$runFeatureFile.call(Unknown Source)
at WSVerification1575894874611.run(WSVerification1575894874611:2)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.WSVerificationExecutor.runScript(WSVerificationExecutor.java:146)
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:140)
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:123)
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:115)
at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:103)
at com.kms.katalon.core.main.TestCaseMain.runFeatureFile(TestCaseMain.java:144)
at com.kms.katalon.core.main.TestCaseMain$runFeatureFile$0.call(Unknown Source)
at TempTempCase1575894872671.run(TempTempCase1575894872671.groovy:23)

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