Answer the question
In order to leave comments, you need to log in
Is it good to make fields (WebElements) public in PageObject implementation?
The fact is that operations with some elements are really simple: click, enter a value, etc.
How bad/good practice is it to make PageObject fields public?
Answer the question
In order to leave comments, you need to log in
This is your personal kitchen, as you decide with your colleagues, do it. )
But I am of the opinion that in PageObject it is necessary to keep not fields but logic.
Here you have a button for throwing goods into the basket, you made a field in PO
(By, or WebElement, or some other wrapper is not important). Now in several tests you use it
@Test
publuc void UserShoudBeAdblePay(){
...
driver.findElement(pay).click();
}
public void putInBasket() {
driver.findElement(By.id("pay")).click();
}
public void putInBasket() {
driver.findElement(By.id("drop-down")).click();
driver.findElement(By.id("pay")).click();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question