Answer the question
In order to leave comments, you need to log in
Is it possible to write validations inside the Page object?
public class ToDoTestPage {
public WebDriver driver;
String actualTitle;
public ToDoTestPage(WebDriver driver) {
PageFactory.initElements(driver, this); // lazy proxy
this.driver = driver;
}
@FindBy(css = "body > section > div > header > h1")
private WebElement el1;
@FindBy(css = "body > aside > ul:nth-child(8) > li:nth-child(3) > a")
private WebElement el4;
@FindBy(css = "body > section > div > header > input")
private WebElement el2;
@FindBy(xpath = "//div/input")
private WebElement el5;
@FindBy(xpath = "//button")
private WebElement el7;
@FindBy(css = "body > section > div > footer > ul > li:nth-child(3) > a")
private WebElement el3;
public ToDoTestPage shouldBeFirstTitleOnTheWebPage(String s) {
Assert.assertEquals("React • TodoMVC", driver.getTitle());
return ToDoTestPage.this;
}
public ToDoTestPage shouldHaveTittle(String toDos) {
el1.isDisplayed();
return ToDoTestPage.this;
}
public ToDoTestPage shouldNotbeClickable(String s) {
el4.getAttribute("irc://chat.freenode.net/reactjs");
return ToDoTestPage.this;
}
public ToDoTestPage input(String s) {
el2.sendKeys("Learn to Code HTML & CSS is a simple", Keys.ENTER);
return ToDoTestPage.this;
}
public ToDoTestPage shouldBeDeleted(String s) {
el7.click();
return ToDoTestPage.this;
}
public ToDoTestPage click(String active_button) {
el3.click();
return ToDoTestPage.this;
}
public ToDoTestPage shouldBeCompleted(String s) {
el5.click();
(new WebDriverWait(driver , 4)).until(ExpectedConditions.elementToBeSelected(By.xpath("//div/input")));
return ToDoTestPage.this;
}
}
Answer the question
In order to leave comments, you need to log in
What kind of checks? Page Object is an abstraction over the elements of the page,
checking for their (elements) presence is the task of the tests themselves, and not of the elements ...
How can the markup of the shopping cart page, for example, check anything?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question