serenity BDD: how to reuse test steps(@steps) as we do in cucumber BDD (i.e. using pico container )

250 views
Skip to first unread message

AMAN PATWAL

unread,
May 10, 2018, 3:00:20 AM5/10/18
to Serenity BDD Users Group

Using Serenity BDD +selenium+Junit for automation.i am new to serenity BDD but  have experience in cucumber BDD where we can easily share steps.i want to achieve the same in serenity. For simplicity let's say we have a Login page and a subsequent page say Name Check Page. I have created individual POM for these two pages and then corresponding step definitions(@steps) and wanted to use @steps defined in these two step definition classes in single script. Can this be done?

1)I have tried using this but browser closes as soon the step in particular step class finishes so other steps do not get executed and gives exception


public class AA_NameCheck{

@Managed(driver="edge",clearCookies=ClearCookiesPolicy.BeforeEachTest)
WebDriver driver;

@Steps
StepsLoginPage stepL;
StepsNameCheckPage stepN;

@Test
public void NameCheck_ValidUser() throws InterruptedException{
    stepL.Launch();
    stepL.Login_ValidCredential();
    stepN.Enter_NameDetails();

    }

After stepL.Login_validCredentials() finishes browser gets close and thus exception occur on methods on Name_EnterDetails()


2)i have tried instead of creating separate step definition keeping the @steps in POM ,it worked but the steps are then not visible in serenity report.


Just wanted to know any other approach is possible for sharing steps?

Imam hasan

unread,
May 29, 2018, 2:40:53 PM5/29/18
to Serenity BDD Users Group
Please write like below,

@Steps
StepsLoginPage stepL;
@Steps
StepsNameCheckPage stepN;

AMAN PATWAL

unread,
Jun 1, 2018, 9:03:38 AM6/1/18
to Serenity BDD Users Group
Thanks Imam for your kind help ,the issue is resolved now.
Reply all
Reply to author
Forward
0 new messages