hello297
hello297

Reputation: 15

What is better practice in Cucumber-jvm

We are at odds in the office over what is the better way to structure our cucumber test suite. This is in the context of clicking radio buttons in forms. The two approaches are:

  1. Use the page object model. Have the radio buttons defined as web elements in the page object and pass in the value to select the option as input in the feature file.
  2. Pass a selector (the element attribute "name") and value as inputs in the feature file. By passing the selector and value, all we would need is a method that clicks on the option dynamically according to the selector and value passed.

Option 1:

Pros:

Option 2:

Pros:

In my opinion, option 2 might be better for the short term but as we develop more and scale up, having webElements defined in classes will be more beneficial. And I'm also thinking that development using option 2 is actually going to be clunkier since you need to find the selector each time you use it.

We both think that the other is objectively worse but can't come to an agreement. Is either one objectively better? Which is better practice from an industry standard point of view?

Upvotes: 0

Views: 33

Answers (1)

Szabo Peter
Szabo Peter

Reputation: 514

I'd choose page objects instead of selectors in the feature files without a second thought because feature files and page object should represent different levels of abstraction. Page objects can of course share common functionality any way you see fit to reduce bloat.

Upvotes: 1

Related Questions