-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from GEdO23/dev
Testes com Cucumber e correção de bug com cadastro de Pets e Raças
- Loading branch information
Showing
14 changed files
with
258 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# language: pt | ||
|
||
@Login | ||
Funcionalidade: Login | ||
|
||
@LoginValido @SmokeTest | ||
Cenário: Login com credenciais validas | ||
Dado que estou na tela de login | ||
Quando entro com credenciais validas | ||
E clico no botao de submit | ||
Entao vejo a tela Home | ||
|
||
@LoginInvalido | ||
Cenário: Login com username invalido | ||
Dado que estou na tela de login | ||
Quando entro com username invalido | ||
E clico no botao de submit | ||
Entao vejo a mensagem de erro | ||
|
||
@LoginInvalido | ||
Cenário: Login com password invalido | ||
Dado que estou na tela de login | ||
Quando entro com password invalido | ||
E clico no botao de submit | ||
Entao vejo a mensagem de erro | ||
|
||
@SignOff | ||
Cenário: Realizar o Sign Off | ||
Dado que estou na tela de login | ||
Quando entro com credenciais validas | ||
E clico no botao de submit | ||
Entao vejo a tela Home | ||
Quando clico no botao Sign Off | ||
Entao vejo a mensagem de Logout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package pages; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
import utils.Setup; | ||
|
||
import java.time.Duration; | ||
|
||
public class BasePage extends Setup { | ||
|
||
protected WebElement waitElement(By locator) { | ||
return new WebDriverWait(driver, Duration.ofSeconds(10)) | ||
.until(ExpectedConditions.presenceOfElementLocated(locator)); | ||
} | ||
|
||
protected boolean isVisible(By locator) { | ||
waitElement(locator); | ||
return driver.findElement(locator).isDisplayed(); | ||
} | ||
|
||
protected void fillInput(By locator, String text) { | ||
isVisible(locator); | ||
driver.findElement(locator).sendKeys(text); | ||
} | ||
|
||
protected void click(By locator) { | ||
isVisible(locator); | ||
driver.findElement(locator).click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package pages; | ||
|
||
import org.openqa.selenium.By; | ||
|
||
public class HomePage extends BasePage { | ||
|
||
public final By title = By.id("home-title"); | ||
public final By btnSair = By.id("btn-sair"); | ||
|
||
public void isOnHomePage() { | ||
isVisible(title); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package pages; | ||
|
||
import org.openqa.selenium.By; | ||
|
||
public class LoginPage extends BasePage { | ||
|
||
public final String validUserName = "Gabriel"; | ||
public final String validUserPassword = "12345"; | ||
|
||
public final By etUserName = By.id("username"); | ||
public final By etUserPassword = By.id("password"); | ||
public final By btnSignIn = By.id("btn-signin"); | ||
|
||
public final By tvLoginError = By.id("alert-invalid-user"); | ||
public final By tvLogoutSuccess = By.id("alert-logout-success"); | ||
|
||
public void fillUserName() { | ||
fillInput(etUserName, validUserName); | ||
} | ||
|
||
public void fillUserPassword() { | ||
fillInput(etUserPassword, validUserPassword); | ||
} | ||
|
||
public void clickBtnSignIn() { | ||
click(btnSignIn); | ||
} | ||
|
||
public void isOnLoginPage() { | ||
driver.get("http://localhost:8080/login"); | ||
isVisible(btnSignIn); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package stepDefinition; | ||
|
||
import io.cucumber.java.After; | ||
import io.cucumber.java.Before; | ||
import utils.Setup; | ||
|
||
import static utils.Setup.driver; | ||
|
||
public class Hooks { | ||
|
||
@Before | ||
public void setupDriver() { | ||
Setup.createDriverInstance(); | ||
} | ||
|
||
@After | ||
public void closeDriver() { | ||
Setup.quitDriver(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package stepDefinition; | ||
|
||
import io.cucumber.java.pt.Dado; | ||
import io.cucumber.java.pt.E; | ||
import io.cucumber.java.pt.Entao; | ||
import io.cucumber.java.pt.Quando; | ||
import pages.BasePage; | ||
import pages.HomePage; | ||
import pages.LoginPage; | ||
|
||
public class LoginSteps extends BasePage { | ||
|
||
LoginPage login = new LoginPage(); | ||
HomePage home = new HomePage(); | ||
|
||
@Dado("que estou na tela de login") | ||
public void queEstouNaTelaDeLogin() { | ||
login.isOnLoginPage(); | ||
} | ||
|
||
@Quando("entro com credenciais validas") | ||
public void entroComCredenciaisValidas() { | ||
login.fillUserName(); | ||
login.fillUserPassword(); | ||
} | ||
|
||
@E("clico no botao de submit") | ||
public void clicoNoBotaoDeSubmit() { | ||
login.clickBtnSignIn(); | ||
} | ||
|
||
@Entao("vejo a tela Home") | ||
public void vejoATelaHome() { | ||
home.isOnHomePage(); | ||
} | ||
|
||
@Quando("entro com username invalido") | ||
public void entroComUsernameInvalido() { | ||
fillInput(login.etUserName, "invalid user"); | ||
login.fillUserPassword(); | ||
} | ||
|
||
@Quando("entro com password invalido") | ||
public void entroComPasswordInvalido() { | ||
login.fillUserName(); | ||
fillInput(login.etUserPassword, "invalid password"); | ||
} | ||
|
||
@Entao("vejo a mensagem de erro") | ||
public void vejoAMensagemDeErro() { | ||
isVisible(login.tvLoginError); | ||
} | ||
|
||
@Entao("vejo a mensagem de Logout") | ||
public void vejoAMensagemDeLogout() { | ||
isVisible(login.tvLogoutSuccess); | ||
} | ||
|
||
@Quando("clico no botao Sign Off") | ||
public void clicoNoBotaoSignOff() { | ||
isVisible(home.btnSair); | ||
click(home.btnSair); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package utils; | ||
|
||
import org.openqa.selenium.PageLoadStrategy; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import org.openqa.selenium.chrome.ChromeOptions; | ||
|
||
|
||
public class Setup { | ||
|
||
public static WebDriver driver; | ||
|
||
public static WebDriver createDriverInstance() { | ||
ChromeOptions options = new ChromeOptions(); | ||
options.setPageLoadStrategy(PageLoadStrategy.NORMAL); | ||
driver = new ChromeDriver(options); | ||
driver.manage().window().maximize(); | ||
return driver; | ||
} | ||
|
||
public static void quitDriver() { | ||
driver.quit(); | ||
} | ||
} |