PageObjects
23/08/2019
0
Boa tarde a todos! eu não estou entendo porque ao utilizar o page objects o site abre clica em signup mas não preenche o cadastro? antes quando estava tudo em uma classe preenchia normalmente, segue as páginas:
package br.com.adrianoabner.webdriverJava;
import static org.junit.Assert.assertEquals;
import java.util.concurrent.TimeUnit;
import org.easetech.easytest.annotation.DataLoader;
import org.easetech.easytest.annotation.Param;
import org.easetech.easytest.runner.DataDrivenTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import Pages.SecretaPage;
import Pages_Taskit.CadastroPage;
@RunWith(DataDrivenTestRunner.class)
@DataLoader(filePaths = "test.csv")
public class PageObjectsTaskit {
private WebDriver navegador;
@Before
public void setUp(){
System.setProperty("webdriver.chrome.driver","C:\\\\\\\\Users\\\\\\\\Adriano Abner\\\\\\\\drivers\\\\\\\\chromedriver.exe");
navegador = new ChromeDriver();
navegador.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
navegador.manage().window().maximize();
navegador.get("http://www.juliodelima.com.br/taskit");
}
@Test
public void test(
@Param(name= "name")String nome,
@Param(name= "login")String login,
@Param(name= "password")String password,
@Param(name= "mensagem")String mensagem
) {
SecretaPage textoToast = new CadastroPage(navegador).clickSignUp()
.fazerLogin(nome, login, password);
assertEquals(mensagem,textoToast);
}
}
package Pages_Taskit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class BasePage {
protected WebDriver navegador;
public BasePage(WebDriver navegador) {
this.navegador = navegador;
}
public String capturarTextoToast() {
// Na menssagem de id "toast-container " validar que o texto é "Hi, Adriano Abner "
return navegador.findElement(By.id("toast-container")).getText();
}
}
package Pages_Taskit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import Pages.LoginFormPage;
import Pages.SecretaPage;
public class CadastroPage extends BasePage {
public CadastroPage(WebDriver navegador) {
super(navegador);
// TODO Auto-generated constructor stub
}
public void adicionarNome() {
/*navegador.findElement(By.id("signup")).click();
navegador.findElement(By.name("name")).sendKeys("nome");
navegador.findElement(By.name("login")).sendKeys("login");
navegador.findElement(By.name("password")).sendKeys("password");
navegador.findElement(By.linkText("SAVE")).click();
*/
}
public CadastroPage clickSignUp() {
navegador.findElement(By.id("signup")).click();
return this;
}
public CadastroPage typeName(String nome){
navegador.findElement(By.id("signupbox")).findElement(By.name("name")).sendKeys(nome);
return this;
}
public CadastroPage typeLogin(String login){
navegador.findElement(By.id("signupbox")).findElement(By.name("login")).sendKeys(login);
return this;
}
public CadastroPage typePassword(String password) {
navegador.findElement(By.id("signupbox")).findElement(By.name("password")).sendKeys(password);
return this;
}
public SecretaPage fazerLogin(String nome,String login,String password) {
typeName(nome);
typeLogin(login);
typePassword(password);
clickSignUp();
return new SecretaPage(navegador);
}
}
package Pages_Taskit;
import org.openqa.selenium.WebDriver;
public class SecretaPage extends BasePage{
public SecretaPage(WebDriver navegador) {
super(navegador);
// TODO Auto-generated constructor stub
}
}
test,nome,login,password,mensagem
, AdrianoAbner,adr20123,123456,Hi, Adriano Abner
, AdrianoZ,ad123,2456789,Hi, Adriano Abner
, AdrianoBarbosa,ad1236554,654699875,Hi, Adriano Abner
package br.com.adrianoabner.webdriverJava;
import static org.junit.Assert.assertEquals;
import java.util.concurrent.TimeUnit;
import org.easetech.easytest.annotation.DataLoader;
import org.easetech.easytest.annotation.Param;
import org.easetech.easytest.runner.DataDrivenTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import Pages.SecretaPage;
import Pages_Taskit.CadastroPage;
@RunWith(DataDrivenTestRunner.class)
@DataLoader(filePaths = "test.csv")
public class PageObjectsTaskit {
private WebDriver navegador;
@Before
public void setUp(){
System.setProperty("webdriver.chrome.driver","C:\\\\\\\\Users\\\\\\\\Adriano Abner\\\\\\\\drivers\\\\\\\\chromedriver.exe");
navegador = new ChromeDriver();
navegador.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
navegador.manage().window().maximize();
navegador.get("http://www.juliodelima.com.br/taskit");
}
@Test
public void test(
@Param(name= "name")String nome,
@Param(name= "login")String login,
@Param(name= "password")String password,
@Param(name= "mensagem")String mensagem
) {
SecretaPage textoToast = new CadastroPage(navegador).clickSignUp()
.fazerLogin(nome, login, password);
assertEquals(mensagem,textoToast);
}
}
package Pages_Taskit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class BasePage {
protected WebDriver navegador;
public BasePage(WebDriver navegador) {
this.navegador = navegador;
}
public String capturarTextoToast() {
// Na menssagem de id "toast-container " validar que o texto é "Hi, Adriano Abner "
return navegador.findElement(By.id("toast-container")).getText();
}
}
package Pages_Taskit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import Pages.LoginFormPage;
import Pages.SecretaPage;
public class CadastroPage extends BasePage {
public CadastroPage(WebDriver navegador) {
super(navegador);
// TODO Auto-generated constructor stub
}
public void adicionarNome() {
/*navegador.findElement(By.id("signup")).click();
navegador.findElement(By.name("name")).sendKeys("nome");
navegador.findElement(By.name("login")).sendKeys("login");
navegador.findElement(By.name("password")).sendKeys("password");
navegador.findElement(By.linkText("SAVE")).click();
*/
}
public CadastroPage clickSignUp() {
navegador.findElement(By.id("signup")).click();
return this;
}
public CadastroPage typeName(String nome){
navegador.findElement(By.id("signupbox")).findElement(By.name("name")).sendKeys(nome);
return this;
}
public CadastroPage typeLogin(String login){
navegador.findElement(By.id("signupbox")).findElement(By.name("login")).sendKeys(login);
return this;
}
public CadastroPage typePassword(String password) {
navegador.findElement(By.id("signupbox")).findElement(By.name("password")).sendKeys(password);
return this;
}
public SecretaPage fazerLogin(String nome,String login,String password) {
typeName(nome);
typeLogin(login);
typePassword(password);
clickSignUp();
return new SecretaPage(navegador);
}
}
package Pages_Taskit;
import org.openqa.selenium.WebDriver;
public class SecretaPage extends BasePage{
public SecretaPage(WebDriver navegador) {
super(navegador);
// TODO Auto-generated constructor stub
}
}
test,nome,login,password,mensagem
, AdrianoAbner,adr20123,123456,Hi, Adriano Abner
, AdrianoZ,ad123,2456789,Hi, Adriano Abner
, AdrianoBarbosa,ad1236554,654699875,Hi, Adriano Abner
Adriano Barbosa
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)