Skip to content

Commit

Permalink
Merge pull request #5 from diegoquirino/v6.0-selenide
Browse files Browse the repository at this point in the history
V6.0 selenide
  • Loading branch information
diegoquirino authored Jan 16, 2019
2 parents 24adf53 + f1640c8 commit abe63e6
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 94 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target
build
.idea
*.iml
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<serenity.version>2.0.32</serenity.version>
<serenity.cucumber.version>1.9.23</serenity.cucumber.version>
<applitools.version>3.143.1</applitools.version>
<selenide.version>5.1.0</selenide.version>
<webdriver.gecko.driver>C:\\ambiente\\geckodriver.exe</webdriver.gecko.driver>
</properties>

Expand Down Expand Up @@ -97,6 +98,12 @@
<artifactId>eyes-selenium-java3</artifactId>
<version>${applitools.version}</version>
</dependency>
<!-- Dependências Selenide -->
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>${selenide.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import br.pro.diegoquirino.calculadora.ux.EyesSingleton;
import br.pro.diegoquirino.calculadora.ux.pages.CompartilhadosPageObject;
import br.pro.diegoquirino.calculadora.ux.pages.PaginaInicialPageObject;
import com.applitools.eyes.RectangleSize;
import net.thucydides.core.annotations.Managed;
import net.thucydides.core.annotations.Step;
import net.thucydides.core.steps.ScenarioSteps;
import net.thucydides.core.webdriver.WebDriverFacade;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
package br.pro.diegoquirino.calculadora.ux;

import com.applitools.eyes.RectangleSize;
import com.applitools.eyes.exceptions.DiffsFoundException;
import com.applitools.eyes.selenium.Eyes;
import net.thucydides.core.webdriver.WebDriverFacade;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.awt.*;

public class EyesSingleton {

Expand All @@ -25,7 +19,7 @@ public static Eyes get() {
eyes = new Eyes();
// Change or Externalize a APIKEY para a da sua conta, a fim de que seja possível gerenciar mudanças
// e planos de execução
eyes.setApiKey("<<SUA APIKEY AQUI!!!>>>");
eyes.setApiKey("<<SUA APIKEY>>");
}
return eyes;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package br.pro.diegoquirino.calculadora.ux.REQ002_AjudaDoSistema;

import br.pro.diegoquirino.calculadora.ux.pages.AjudaDoSistemaPageObject;
import br.pro.diegoquirino.calculadora.ux.pages.PaginaInicialPageObject;
import net.thucydides.core.annotations.Step;
import net.thucydides.core.steps.ScenarioSteps;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
package br.pro.diegoquirino.calculadora.ux.pages;

import net.serenitybdd.core.pages.PageObject;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindAll;
import org.openqa.selenium.support.FindBy;

import java.util.List;
import static com.codeborne.selenide.Selenide.*;
import static com.codeborne.selenide.Condition.*;

public class AjudaDoSistemaPageObject extends PageObject {
public class AjudaDoSistemaPageObject {

@FindBy(id = "welcome.button.ajuda")
private WebElement buttonBody;

@FindBy(xpath = "/html/body/div[1]/div[2]/h1")
private WebElement pageTitle;

@FindAll(@FindBy(xpath = "//h2"))
private List<WebElement> sections;

public void acessarButtonBodyAjuda() {
this.buttonBody.click();
public static void acessarButtonBodyAjuda() {
$(By.id("welcome.button.ajuda")).click();
}

public String getAjudaPageTitle() {
return this.pageTitle.getText();
public static String getAjudaPageTitle() {
return $(By.xpath("/html/body/div[1]/div[2]/h1")).getText();
}

public boolean existeSecao(String nomeDaSecao) {
for(WebElement sec : sections) {
public static boolean existeSecao(String nomeDaSecao) {
for(WebElement sec : $$(By.xpath("//h2"))) {
if(sec.getText().equalsIgnoreCase(nomeDaSecao)){
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
package br.pro.diegoquirino.calculadora.ux.pages;

import net.serenitybdd.core.pages.PageObject;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import static com.codeborne.selenide.Selenide.*;

public class CompartilhadosPageObject extends PageObject {
import net.serenitybdd.core.annotations.findby.By;
import static com.codeborne.selenide.Condition.*;

@FindBy(id = "index.navlink.ajuda")
private WebElement linkMenuAjuda;
public class CompartilhadosPageObject {

@FindBy(id = "index.navlink.contato")
private WebElement linkMenuContato;


public void acessarLinkMenuAjuda() {
this.linkMenuAjuda.click();
public static void acessarLinkMenuAjuda() {
$(By.id("index.navlink.ajuda")).shouldHave(text("Ajuda")).click();
}

public void acessarLinkMenuContato() {
this.linkMenuContato.click();
public static void acessarLinkMenuContato() {
$(By.id("index.navlink.contato")).shouldHave(text("Contato")).click();
}

}
Original file line number Diff line number Diff line change
@@ -1,69 +1,39 @@
package br.pro.diegoquirino.calculadora.ux.pages;

import net.serenitybdd.core.pages.PageObject;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.By;

import java.text.Normalizer;
import java.util.List;

public class MensagemDeContatoPageObject extends PageObject {
import static com.codeborne.selenide.Selenide.*;
import static com.codeborne.selenide.Condition.*;

@FindBy(id="nome")
private WebElement campoNome;
public class MensagemDeContatoPageObject {

@FindBy(id="email")
private WebElement campoEmail;

@FindBy(name="tipoMsg")
private List<WebElement> radioTipoMensagem;

@FindBy(id="idade")
private WebElement selectIdade;

@FindBy(id="mensagem")
private WebElement campoMensagem;

@FindBy(id="contato.button.enviarMensagem")
private WebElement botaoEnviar;

@FindBy(xpath = "//body")
private WebElement conteudo;

public void preencherNome(String nome){
campoNome.clear();
campoNome.sendKeys(nome);
public static void preencherNome(String nome){
$(By.id("nome")).setValue(nome);
}
public void preencherEmail(String email){
campoEmail.clear();
campoEmail.sendKeys(email);
public static void preencherEmail(String email){
$(By.id("email")).setValue(email);
}
public void preencherMensagem(String msg){
campoMensagem.clear();
campoMensagem.sendKeys(msg);
public static void preencherMensagem(String msg){
$(By.id("mensagem")).setValue(msg);
}

public void escolherTipoDeMensagem(String tipo){
for(WebElement e: radioTipoMensagem){
String value = e.getAttribute("value");
if(value.contains(removerAcentos(tipo.toLowerCase()))){
e.click();
}
}
public static void escolherTipoDeMensagem(String tipo){
$(By.name("tipoMsg")).selectRadio(removerAcentos(tipo.toLowerCase()));
}

public void escolherIdade(String idade) {
Select s = new Select(selectIdade);
s.selectByVisibleText(idade);
public static void escolherIdade(String idade) {
$(By.id("idade")).selectOptionContainingText(idade);
}

public void enviar(){
botaoEnviar.click();
public static void enviar(){
$(By.id("contato.button.enviarMensagem")).shouldBe(enabled).submit();
}

public String getConteudo(){
return conteudo.getText();
public static String getConteudo(){
return $(By.xpath("//body")).getText();
}

private static String removerAcentos(String str) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package br.pro.diegoquirino.calculadora.ux.pages;

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.WebDriverRunner;
import net.serenitybdd.core.pages.PageObject;
import net.thucydides.core.webdriver.WebDriverFacade;

public class PaginaInicialPageObject extends PageObject {

public void acessarPaginaInicial(){
this.getDriver().manage().window().maximize();
this.getDriver().get("http://diegoquirino.pro.br/calculadora");
// Passando o driver de execução para o Selenide
WebDriverRunner.setWebDriver(((WebDriverFacade)this.getDriver()).getProxiedDriver());
WebDriverRunner.getWebDriver().manage().window().maximize();
Selenide.open("http://diegoquirino.pro.br/calculadora");
}

}

0 comments on commit abe63e6

Please sign in to comment.