vendredi 26 juillet 2019

Test with multipage methods (Page Objects) - Selenium Webdriver

I have the following problem:

I can only call the method (.confirmaLogin) from the same page (class). Why can't I add methods from other pages?

First page (class):

                public class loginSIGE {
    public WebDriver browser;
    public loginSIGE(WebDriver browser) {
        this.browser = browser;
    }
    public loginSIGE confirmaLogin() {
        browser.findElement(By.xpath("//button[@class=\"btn btn-primary btn-block btn-flat\"]")).click();
        return new telaPrincipal(browser);
    }


Second page:

public class telaPrincipal extends loginSIGE {
    public telaPrincipal(WebDriver browser) {
        super(browser);
    }
    public telaPrincipal cliqueDenuncia() {
        browser.findElement(By.linkText("Denuncias")).click();
        return new telaDenuncia (browser);
    }

Test:

  public void acesso() {
        new loginSIGE(browser)
               .confirmaLogin();


I can't add the second page method!

I look forward and thank you in advance

Aucun commentaire:

Enregistrer un commentaire