Is it possible to reuse BDD steps - Call steps inside other steps

Hi:

I saw that Katalon can call Test cases inside another Test case, but I could not find If I can call BDD steps in other steps (reuse the steps already create). Please, could you confirm if this feature is supported by Katalon?

have you tried to call the step as method? for exemple

@Then(“I should see the Home page”)

def I_should_see_the_Home_page() {

I_should_verify_the_button()

String CurrentURL= WebUI.getUrl()

WebUI.verifyMatch(CurrentURL, GlobalVariable.G_Site_URL + ‘/’, false)

}

@Then(“I should verify the button”)

def I_should_verify_the_button() {

WebUI.waitForElementVisible(findTestObject(‘Object Repository’), 300)

WebUI.waitForElementVisible(findTestObject(‘Object Repository2’), 300)

}

1 Like

If you are calling it from the same step definition, you can just call it directly. However, if you calls it from other step definition, you need to import the file and calls it.

import com.something.MyClass
ex: new MyClass().I_have_a_function()

1 Like