Skip to content

Commit

Permalink
Projeto de Teste Mobile da Lojinha
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Barbosa committed Jun 11, 2022
0 parents commit 72e9b87
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
target/
35 changes: 35 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>lojinhaMobileAutomacao</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.0-M1</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.1.1</version>
</dependency>


</dependencies>

</project>
61 changes: 61 additions & 0 deletions src/test/java/modulos/produto/ProdutoTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package modulos.produto;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.Remote;
import java.util.concurrent.TimeUnit;

@DisplayName("Testes Mobile do Módulo de Produto")
public class ProdutoTest {
@DisplayName("Validação do Valor de Produto Não Permitido")
@Test
public void testValidacaoDoValorDeProdutoNaoPermitido () throws MalformedURLException {
// Abrir o App
DesiredCapabilities capacidades = new DesiredCapabilities();
capacidades.setCapability("deviceName", "Xiaomi de Fernando");
capacidades.setCapability("platform", "Android");
capacidades.setCapability("udid", "59f5ce700406");
capacidades.setCapability("appPackage", "com.lojinha");
capacidades.setCapability("appActivity", "com.lojinha.ui.MainActivity");
capacidades.setCapability("app", "C:\\Users\\ferna\\Documents\\lojinha-nativa.apk");

WebDriver app = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capacidades);
app.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);


// Fazer Login
app.findElement(By.id("com.lojinha:id/user")).click();
app.findElement(By.id("com.lojinha:id/user")).findElement(By.id("com.lojinha:id/editText")).sendKeys("admin");

app.findElement(By.id("com.lojinha:id/password")).click();
app.findElement(By.id("com.lojinha:id/password")).findElement(By.id("com.lojinha:id/editText")).sendKeys("admin");

app.findElement(By.id("com.lojinha:id/loginButton")).click();

// Abrir o formulário de novo produto
app.findElement(By.id("com.lojinha:id/floatingActionButton")).click();

// Cadastrar um produto com valor inválido
app.findElement(By.id("com.lojinha:id/productName")).click();
app.findElement(By.id("com.lojinha:id/productName")).findElement(By.id("com.lojinha:id/editText")).sendKeys("Notebook");
app.findElement(By.id("com.lojinha:id/productValue")).click();
app.findElement(By.id("com.lojinha:id/productValue")).findElement(By.id("com.lojinha:id/editText")).sendKeys("750000");
app.findElement(By.id("com.lojinha:id/productColors")).click();
app.findElement(By.id("com.lojinha:id/productColors")).findElement(By.id("com.lojinha:id/editText")).sendKeys("Vermelho");

app.findElement(By.id("com.lojinha:id/saveButton")).click();


// Validar que a mensagem de valor invalido foi apresentada
String mensagenApresentada = app.findElement(By.xpath("//android.widget.Toast")).getText();
Assertions.assertEquals("O valor do produto deve estar entre R$ 0,01 e R$ 7.000,00", mensagenApresentada);
}
}

0 comments on commit 72e9b87

Please sign in to comment.