I'm trying to figure out the best way of making my Page Objects simple, and whether to put absolutely all logic elsewhere. And whether all Selenium code/functionality should be in the Page Object, or in the Step Definition methods I use to access it.
I have the following structure:
Cucumber.feature files
Given blablablaJava/Kotlin step definitions
@Given("^blablabla$") {}And the page object files
fun getOwnerFields(): MutableList<WebElement> { return driver.findElements(By.if("owner-fields")}As a simple example.
Now, what I cannot come to an agreement with myself on, or find much of other's opinions about, is:
Should I do page actions - for instance, a button click, in the Step Definition class OR in the Page Object?
This:
@Given("^I click on the Next button$") { startPage.nextButton().click()}PO:fun nextButton(): WebElement { return driver.findElement(By.id("next-button")}Or:v
@Given("^I click on the Next button$") { startPage.clickNextButton()}PO:fun clickNextButton(): WebElement { return driver.findElement(By.id("next-button").click()}I've tended to think that it's best to keep all the page and selenium code in the Page Object. But in cases like this, it makes the PO bigger, because I'll need different methods for clicking, checking for visibility, counting etc. While if all this is done in the step definitions, the PO can practically contain nothing but getters and setters for the page elements.
Anyone got any light to shed? I know it's not THAT important, but I tend to be quite occupied with the best and/or cleanest way of organizing my code.