';
252 |
253 | if (typeof module !== 'undefined') {
254 | module.exports = CucumberHTML;
255 | } else if (typeof define !== 'undefined') {
256 | define([], function() { return CucumberHTML; });
257 | }
258 |
--------------------------------------------------------------------------------
/RestAssured/target/report-html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
Cucumber Features
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/RestAssured/target/report-html/report.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function() {var formatter = new CucumberHTML.DOMFormatter($('.cucumber-report'));formatter.uri("file:src/test/resources/testesFuncionais/Teste.feature");
2 | formatter.feature({
3 | "name": "exemplo de teste de API com Cumcumber",
4 | "description": "Este projeto é um exemplo de testes de API com Cucumber",
5 | "keyword": "Funcionalidade"
6 | });
7 | formatter.scenario({
8 | "name": "Consultar os dados de um usuário;",
9 | "description": "",
10 | "keyword": "Cenário"
11 | });
12 | formatter.step({
13 | "name": "fazer uma requisicao",
14 | "keyword": "Quando "
15 | });
16 | formatter.match({
17 | "location": "stepDefinitions.Step.fazerUmaRequisicao()"
18 | });
19 | formatter.result({
20 | "status": "passed"
21 | });
22 | formatter.step({
23 | "name": "devo visualizar os dados",
24 | "keyword": "Entao "
25 | });
26 | formatter.match({
27 | "location": "stepDefinitions.Step.devoVisualizarOsDados()"
28 | });
29 | formatter.result({
30 | "status": "passed"
31 | });
32 | formatter.scenario({
33 | "name": "Adicionar um novo usuário",
34 | "description": "",
35 | "keyword": "Cenário"
36 | });
37 | formatter.step({
38 | "name": "que quero adicionar um novo usuario",
39 | "keyword": "Dado "
40 | });
41 | formatter.match({
42 | "location": "stepDefinitions.Step.ajdQueroAdicionarUmNovoUsuario()"
43 | });
44 | formatter.result({
45 | "status": "passed"
46 | });
47 | formatter.step({
48 | "name": "fazer um post",
49 | "keyword": "Quando "
50 | });
51 | formatter.match({
52 | "location": "stepDefinitions.Step.fazerUmPost()"
53 | });
54 | formatter.result({
55 | "status": "passed"
56 | });
57 | formatter.step({
58 | "name": "devo receber cadastro com sucesso",
59 | "keyword": "Entao "
60 | });
61 | formatter.match({
62 | "location": "stepDefinitions.Step.devoReceberCadastroComSucesso()"
63 | });
64 | formatter.result({
65 | "status": "passed"
66 | });
67 | });
--------------------------------------------------------------------------------
/RestAssured/target/report-html/style.css:
--------------------------------------------------------------------------------
1 | .cucumber-report .body {
2 | font-family: Helvetica,Arial,sans-serif;
3 | }
4 |
5 | .cucumber-report .keyword {
6 | font-weight: bold;
7 | }
8 |
9 | .cucumber-report .description {
10 | font-style: italic;
11 | margin-left: 20px;
12 | white-space: pre;
13 | }
14 |
15 | .cucumber-report details > section {
16 | margin-left: 20px;
17 | }
18 |
19 | .cucumber-report ol.steps {
20 | list-style-type: none;
21 | margin-top: 0;
22 | margin-bottom: 0;
23 | }
24 |
25 | .cucumber-report .step .embedded-text {
26 | background: #dddddd;
27 | }
28 |
29 | .cucumber-report .doc_string {
30 | margin: 0 0 0 20px;
31 | }
32 |
33 | .cucumber-report table {
34 | border-collapse: collapse;
35 | border: 1px;
36 | border-style: solid;
37 | }
38 |
39 | .cucumber-report td, .cucumber-report th {
40 | border: 1px;
41 | border-style: solid;
42 | padding-left: 4px;
43 | padding-right: 4px;
44 | }
45 |
46 | .cucumber-report table {
47 | margin-left: 20px;
48 | }
49 |
50 | .cucumber-report thead {
51 | background-color: #C0C0C0;
52 | }
53 |
54 | .cucumber-report .passed {
55 | background-color: #C5D88A;
56 | }
57 |
58 | .cucumber-report .undefined, .cucumber-report .pending {
59 | background-color: #EAEC2D;
60 | }
61 |
62 | .cucumber-report .skipped {
63 | background-color: #2DEAEC;
64 | }
65 |
66 | .cucumber-report .failed {
67 | background-color: #D88A8A;
68 | }
69 |
70 | .cucumber-report .tags {
71 | display: inline;
72 | }
73 |
74 | .cucumber-report .tag {
75 | margin-right: 0.25em;
76 | color: #246ac1;
77 | }
78 |
79 | .cucumber-report .comments {
80 | display: inline;
81 | }
82 |
83 | .cucumber-report .comment {
84 | margin: 0;
85 | padding: 0;
86 | }
87 |
88 | .cucumber-report .error {
89 | margin: .2em .75em;
90 | padding: .2em;
91 | border: 1px solid #900;
92 | background-color: #EDBBBB;
93 | }
94 |
95 | #cucumber-templates {
96 | display: none;
97 | }
98 |
--------------------------------------------------------------------------------
/RestAssured/target/test-classes/runner/Runner.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/concretesolutions/qa-automation-samples/c8fb94594303445ae792a4b24d7adf9f981e4ba9/RestAssured/target/test-classes/runner/Runner.class
--------------------------------------------------------------------------------
/RestAssured/target/test-classes/stepDefinitions/Step.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/concretesolutions/qa-automation-samples/c8fb94594303445ae792a4b24d7adf9f981e4ba9/RestAssured/target/test-classes/stepDefinitions/Step.class
--------------------------------------------------------------------------------
/RestAssured/target/test-classes/testesFuncionais/Teste.feature:
--------------------------------------------------------------------------------
1 | # language: pt
2 |
3 | Funcionalidade: Teste seu front-end em uma API real
4 |
5 | Como desenvolvedor,
6 | Eu quero realizar uma consulta de usuario,
7 | para que eu possa visualizar, email, primeiro nome e sobrenome.
8 |
9 |
10 | Como desenvolvedor,
11 | Eu inserir novo usuario,
12 | para que eu possa visualizar o cadstro com sucesso.
13 |
14 |
15 | url da aplicacao https://reqres.in/
16 |
17 |
18 |
19 | Cenário: Consultar os dados de um usuário;
20 | Quando fazer uma solicitacao
21 | Entao devo visualizar os dados do usuario
22 |
23 |
24 | Cenário: Adicionar um novo usuário
25 | Dado que quero adicionar um novo usuario
26 | Quando fazer um post
27 | Entao devo realizar cadastro com sucesso
28 |
--------------------------------------------------------------------------------
/appium-java/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/concretesolutions/qa-automation-samples/c8fb94594303445ae792a4b24d7adf9f981e4ba9/appium-java/.gitignore
--------------------------------------------------------------------------------
/appium-java/appium-maven/.gitignore:
--------------------------------------------------------------------------------
1 | ### Eclipse ###
2 |
3 | .metadata
4 | bin/
5 | tmp/
6 | *.tmp
7 | *.bak
8 | *.swp
9 | *~.nib
10 | local.properties
11 | .settings/
12 | .loadpath
13 | .recommenders
14 |
15 | # External tool builders
16 | .externalToolBuilders/
17 |
18 | # Locally stored "Eclipse launch configurations"
19 | *.launch
20 |
21 | # PyDev specific (Python IDE for Eclipse)
22 | *.pydevproject
23 |
24 | # CDT-specific (C/C++ Development Tooling)
25 | .cproject
26 |
27 | # CDT- autotools
28 | .autotools
29 |
30 | # Java annotation processor (APT)
31 | .factorypath
32 |
33 | # PDT-specific (PHP Development Tools)
34 | .buildpath
35 |
36 | # sbteclipse plugin
37 | .target
38 |
39 | # Tern plugin
40 | .tern-project
41 |
42 | # TeXlipse plugin
43 | .texlipse
44 |
45 | # STS (Spring Tool Suite)
46 | .springBeans
47 |
48 | # Code Recommenders
49 | .recommenders/
50 |
51 | # Annotation Processing
52 | .apt_generated/
53 |
54 | # Scala IDE specific (Scala & Java development for Eclipse)
55 | .cache-main
56 | .scala_dependencies
57 | .worksheet
58 |
59 | ### Eclipse Patch ###
60 | # Eclipse Core
61 | .project
62 |
63 | # JDT-specific (Eclipse Java Development Tools)
64 | .classpath
65 |
66 | # Annotation Processing
67 | .apt_generated
68 |
69 | .sts4-cache/
70 |
71 | ### Intellij ###
72 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
73 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
74 |
75 | # User-specific stuff
76 | .idea/**/workspace.xml
77 | .idea/**/tasks.xml
78 | .idea/**/usage.statistics.xml
79 | .idea/**/dictionaries
80 | .idea/**/shelf
81 |
82 | # Generated files
83 | .idea/**/contentModel.xml
84 |
85 | # Sensitive or high-churn files
86 | .idea/**/dataSources/
87 | .idea/**/dataSources.ids
88 | .idea/**/dataSources.local.xml
89 | .idea/**/sqlDataSources.xml
90 | .idea/**/dynamic.xml
91 | .idea/**/uiDesigner.xml
92 | .idea/**/dbnavigator.xml
93 |
94 | # Gradle
95 | .idea/**/gradle.xml
96 | .idea/**/libraries
97 |
98 | # Gradle and Maven with auto-import
99 | # When using Gradle or Maven with auto-import, you should exclude module files,
100 | # since they will be recreated, and may cause churn. Uncomment if using
101 | # auto-import.
102 | # .idea/modules.xml
103 | # .idea/*.iml
104 | # .idea/modules
105 |
106 | # CMake
107 | cmake-build-*/
108 |
109 | # Mongo Explorer plugin
110 | .idea/**/mongoSettings.xml
111 |
112 | # File-based project format
113 | *.iws
114 |
115 | # IntelliJ
116 | out/
117 |
118 | # mpeltonen/sbt-idea plugin
119 | .idea_modules/
120 |
121 | # JIRA plugin
122 | atlassian-ide-plugin.xml
123 |
124 | # Cursive Clojure plugin
125 | .idea/replstate.xml
126 |
127 | # Crashlytics plugin (for Android Studio and IntelliJ)
128 | com_crashlytics_export_strings.xml
129 | crashlytics.properties
130 | crashlytics-build.properties
131 | fabric.properties
132 |
133 | # Editor-based Rest Client
134 | .idea/httpRequests
135 |
136 | # Android studio 3.1+ serialized cache file
137 | .idea/caches/build_file_checksums.ser
138 |
139 | ### Intellij Patch ###
140 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
141 |
142 | # *.iml
143 | # modules.xml
144 | # .idea/misc.xml
145 | # *.ipr
146 |
147 | # Sonarlint plugin
148 | .idea/sonarlint
149 |
150 | ### Java ###
151 | # Compiled class file
152 | *.class
153 |
154 | # Log file
155 | *.log
156 |
157 | # BlueJ files
158 | *.ctxt
159 |
160 | # Mobile Tools for Java (J2ME)
161 | .mtj.tmp/
162 |
163 | # Package Files #
164 | *.jar
165 | *.war
166 | *.nar
167 | *.ear
168 | *.zip
169 | *.tar.gz
170 | *.rar
171 |
172 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
173 | hs_err_pid*
174 |
175 | ### Linux ###
176 | *~
177 |
178 | # temporary files which can be created if a process still has a handle open of a deleted file
179 | .fuse_hidden*
180 |
181 | # KDE directory preferences
182 | .directory
183 |
184 | # Linux trash folder which might appear on any partition or disk
185 | .Trash-*
186 |
187 | # .nfs files are created when an open file is removed but is still being accessed
188 | .nfs*
189 |
190 | ### macOS ###
191 | # General
192 | .DS_Store
193 | .AppleDouble
194 | .LSOverride
195 |
196 | # Icon must end with two \r
197 | Icon
198 |
199 | # Thumbnails
200 | ._*
201 |
202 | # Files that might appear in the root of a volume
203 | .DocumentRevisions-V100
204 | .fseventsd
205 | .Spotlight-V100
206 | .TemporaryItems
207 | .Trashes
208 | .VolumeIcon.icns
209 | .com.apple.timemachine.donotpresent
210 |
211 | # Directories potentially created on remote AFP share
212 | .AppleDB
213 | .AppleDesktop
214 | Network Trash Folder
215 | Temporary Items
216 | .apdisk
217 |
218 | ### Windows ###
219 | # Windows thumbnail cache files
220 | Thumbs.db
221 | ehthumbs.db
222 | ehthumbs_vista.db
223 |
224 | # Dump file
225 | *.stackdump
226 |
227 | # Folder config file
228 | [Dd]esktop.ini
229 |
230 | # Recycle Bin used on file shares
231 | $RECYCLE.BIN/
232 |
233 | # Windows Installer files
234 | *.cab
235 | *.msi
236 | *.msix
237 | *.msm
238 | *.msp
239 |
240 | # Windows shortcuts
241 | *.lnk
242 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/README.md:
--------------------------------------------------------------------------------
1 | #QA Mobile
2 |
3 | QA Mobile is made with Appium.
4 |
5 | ## Components
6 |
7 | * Java 8
8 | * Appium 1.8.1
9 | * Maven
10 | * Android and Ios Simulators or Devices
11 |
12 | ## Running Tests
13 |
14 | 1. Start appium server: `$ appium` ( Use method appiumServerUp to start appium server automatically, and appiumServerDown to close)
15 |
16 | 2. Run implemented android tests: `$ mvn clean test -Dcucumber.options="--tags @implementedForAndroid" -Denv.PLATAFORM=ANDROID_OREO_DEV`
17 |
18 | 3. Run implemented ios tests: `$ mvn clean test -Dcucumber.options="--tags @implementedForIOS" -Denv.PLATAFORM=IPHONE_8_DEV`
19 |
20 | ## IMPORTANT
21 |
22 | * Before run the tests you need to start android device or emulator and appium server.
23 |
24 |
25 | ## OPERATIONAL SYSTEMS FOR TESTS
26 |
27 | ###ANDROID
28 |
29 | * ANDROID_OREO_DEV (Simulator)
30 |
31 | ###IOS
32 |
33 | * IPHONE_6S_DEV (Simulator)
34 |
35 | ## Documentation
36 |
37 | * **[Appium Docs](http://appium.io/)**
38 | * **[Selenium Docs](https://www.seleniumhq.org/docs/)**
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/apps/Appium.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/concretesolutions/qa-automation-samples/c8fb94594303445ae792a4b24d7adf9f981e4ba9/appium-java/appium-maven/apps/Appium.apk
--------------------------------------------------------------------------------
/appium-java/appium-maven/capabilities/android-fisico.json:
--------------------------------------------------------------------------------
1 | {
2 | "platformName": "Android",
3 | "deviceName": "Android",
4 | "platformVersion": "7.0",
5 | "automationName": "UiAutomator2",
6 | "udid": "",
7 | "noReset": true,
8 | "appPackage": "",
9 | "appActivity": "",
10 | "newCommandTimeout": 10
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/capabilities/android-oreo-dev.json:
--------------------------------------------------------------------------------
1 | {
2 | "platformName": "Android",
3 | "deviceName": "Device",
4 | "platformVersion": "7.0",
5 | "automationName": "UiAutomator2",
6 | "udid": "emulator-5554",
7 | "avd": "OREO_API_26",
8 | "fullReset": true,
9 | "newCommandTimeout": 5
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/capabilities/iphone-8-dev.json:
--------------------------------------------------------------------------------
1 | {
2 | "platformName": "iOS",
3 | "platformVersion": "12.0",
4 | "deviceName": "iPhone 8",
5 | "automationName": "XCUITest",
6 | "newCommandTimeout": 5,
7 | "connectHardwareKeyboard": true
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/capabilities/iphone-fisico.json:
--------------------------------------------------------------------------------
1 | {
2 | "udid": "",
3 | "bundleId": "",
4 | "deviceName": "iPhone 6s Plus",
5 | "automationName": "XCUITest",
6 | "noReset": true,
7 | "AutoAcceptAlerts": true,
8 | "newCommandTimeout": 10
9 | }
--------------------------------------------------------------------------------
/appium-java/appium-maven/massa/data/teste.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "José ",
3 | "password": "123456",
4 | "cpf": "00000000011",
5 | "cards": [
6 | "0011"
7 | ]
8 | }
--------------------------------------------------------------------------------
/appium-java/appium-maven/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | 4.0.0
7 |
8 | br.com.appium
9 | appium-maven
10 | 0.0.1-SNAPSHOT
11 | jar
12 |
13 | appium-maven
14 | http://maven.apache.org
15 |
16 |
17 |
18 | UTF-8
19 | 1.8.11
20 | 1.8
21 | 1.8
22 |
23 |
24 |
25 |
26 | junit
27 | junit
28 | 4.12
29 | test
30 |
31 |
32 |
33 | io.appium
34 | java-client
35 | 4.1.2
36 |
37 |
38 |
39 | com.google.code.gson
40 | gson
41 | 2.8.2
42 |
43 |
44 |
45 | io.qameta.allure
46 | allure-cucumber-jvm
47 | 2.0-BETA6
48 |
49 |
50 |
51 | io.cucumber
52 | cucumber-jvm
53 | 3.0.2
54 | pom
55 |
56 |
57 | info.cukes
58 | cucumber-java
59 | 1.2.5
60 | test
61 |
62 |
63 | info.cukes
64 | cucumber-junit
65 | 1.2.5
66 | test
67 |
68 |
69 |
70 |
71 |
72 |
73 | org.apache.maven.plugins
74 | maven-surefire-plugin
75 | 2.20
76 |
77 | 1.8
78 | 1.8
79 |
80 | ${env.PLATAFORM}
81 |
82 |
83 | -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
84 |
85 |
86 |
87 |
88 | allure.results.directory
89 | ${project.build.directory}/allure-results
90 |
91 |
92 | allure.link.issue.pattern
93 | https://alm.accenture.com/jira/browse/{}
94 |
95 |
96 |
97 |
98 |
99 | org.aspectj
100 | aspectjweaver
101 | ${aspectj.version}
102 |
103 |
104 |
105 |
106 | io.qameta.allure
107 | allure-maven
108 | 2.9
109 |
110 | 2.5.0
111 | ${soapui.results.directory}
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/resources/features/teste.feature:
--------------------------------------------------------------------------------
1 | # language: pt
2 |
3 | @teste
4 | Funcionalidade: Teste appium
5 |
6 | @teste01
7 | Cenário: Portador com apenas um cartão para aviso de viagem
8 | Dado que tenha aberto o app
9 | Quando clicar no formulário
10 | E e colocar o meu nome "Fulado"
11 | E salvar a alteração
12 | Então irei visualizar o meu nome na tela
13 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/cucumber/runner/CucumberRunnerTest.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.cucumber.runner;
2 |
3 | import br.com.appium.teste.test.utils.DriverFactoryManager;
4 | import cucumber.api.SnippetType;
5 | import org.junit.AfterClass;
6 | import org.junit.BeforeClass;
7 | import org.junit.runner.RunWith;
8 | import cucumber.api.CucumberOptions;
9 | import cucumber.api.junit.Cucumber;
10 |
11 | @RunWith(Cucumber.class)
12 | @CucumberOptions(monochrome = true, snippets = SnippetType.CAMELCASE,
13 | features = "resources/features",
14 | glue = "br/com/appium/teste/steps/definitions",
15 | tags = {"@teste01","~@unit", "~@notIntegrated"},
16 | plugin = {"io.qameta.allure.cucumberjvm.AllureCucumberJvm", "pretty"})
17 |
18 | public class CucumberRunnerTest {
19 |
20 | @BeforeClass
21 | public static void tearUp() {
22 | DriverFactoryManager.appiumServerUp();
23 | DriverFactoryManager.startDriverByMavenParameter(System.getProperty("environment"));
24 | }
25 |
26 | @AfterClass
27 | public static void tearDown() {
28 | DriverFactoryManager.appiumServerDown();
29 | DriverFactoryManager.quitDriver();
30 | }
31 |
32 | }
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/screens/base/BaseScreen.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.screens.base;
2 |
3 | import io.appium.java_client.MobileElement;
4 | import org.openqa.selenium.By;
5 | import org.openqa.selenium.support.PageFactory;
6 | import br.com.appium.teste.test.utils.DriverFactoryManager;
7 | import io.appium.java_client.pagefactory.AppiumFieldDecorator;
8 | import org.openqa.selenium.support.ui.ExpectedConditions;
9 | import org.openqa.selenium.support.ui.WebDriverWait;
10 |
11 |
12 | public abstract class BaseScreen extends MobileElement {
13 |
14 | public BaseScreen() {
15 | PageFactory.initElements(new AppiumFieldDecorator(DriverFactoryManager.getDriver()), this);
16 | }
17 |
18 | protected void waitForInsvisibilityOfElement(By locator) {
19 | new WebDriverWait(DriverFactoryManager.getDriver(), 5)
20 | .until(ExpectedConditions.invisibilityOfElementLocated(locator));
21 | }
22 |
23 | protected void waitForVisibilityOfElement(By locator) {
24 |
25 | new WebDriverWait(DriverFactoryManager.getDriver(), 5)
26 | .until(ExpectedConditions.visibilityOfElementLocated(locator));
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/screens/login/InitialScreen.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.screens.login;
2 |
3 | import br.com.appium.teste.screens.base.BaseScreen;
4 | import io.appium.java_client.pagefactory.WithTimeout;
5 | import io.appium.java_client.MobileElement;
6 | import io.appium.java_client.pagefactory.AndroidFindBy;
7 | import io.appium.java_client.pagefactory.iOSFindBy;
8 |
9 | import java.util.concurrent.TimeUnit;
10 |
11 | public class InitialScreen extends BaseScreen {
12 |
13 | @WithTimeout(time = 5000, unit = TimeUnit.SECONDS)
14 | @AndroidFindBy(xpath = "//android.widget.TextView[@text='Formulário']")
15 | private MobileElement clickFormulario;
16 |
17 | @AndroidFindBy(accessibility = "nome")
18 | private MobileElement inputNome;
19 |
20 | @AndroidFindBy(xpath = "//android.widget.Button[@content-desc='save']/android.widget.TextView")
21 | private MobileElement save;
22 |
23 | @AndroidFindBy(xpath = "//android.widget.TextView[starts-with(@text,'Nome')]")
24 | private MobileElement assertName;
25 |
26 | public void clickFormulario() {
27 | this.clickFormulario.click();
28 | }
29 |
30 | public void inputNome(String nome) {
31 |
32 | this.inputNome.sendKeys(nome);
33 | }
34 |
35 | public void saveClick() {
36 |
37 | this.save.click();
38 | }
39 |
40 | public boolean assertNome(String nome) {
41 | return this.assertName.getText().contains(nome);
42 |
43 | }
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/steps/definitions/TesteSteps.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.steps.definitions;
2 |
3 | import br.com.appium.teste.screens.login.InitialScreen;
4 | import cucumber.api.java.pt.Dado;
5 | import cucumber.api.java.pt.Entao;
6 | import cucumber.api.java.pt.Quando;
7 |
8 | public class TesteSteps {
9 |
10 | InitialScreen initialScreen;
11 |
12 | public TesteSteps() {
13 |
14 | initialScreen = new InitialScreen();
15 | }
16 |
17 |
18 | @Dado("^que tenha aberto o app$")
19 | public void que_tenha_aberto_o_app() {
20 | }
21 |
22 | @Quando("^clicar no formulário$")
23 | public void clicar_no_formulário() {
24 | this.initialScreen.clickFormulario();
25 | }
26 |
27 | @Quando("^e colocar o meu nome \"([^\"]*)\"$")
28 | public void e_colocar_o_meu_nome(String nome) {
29 | this.initialScreen.inputNome(nome);
30 |
31 | }
32 |
33 | @Quando("^salvar a alteração$")
34 | public void salvar_a_alteração() {
35 | this.initialScreen.saveClick();
36 |
37 | }
38 |
39 | @Entao("^irei visualizar o meu nome na tela$")
40 | public void irei_visualizar_o_meu_nome_na_tela() {
41 | this.initialScreen.assertNome("Fulano");
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/test/constants/Constants.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.test.constants;
2 |
3 | public class Constants {
4 | public static final String APPIUM_URL_DEV = "http://localhost:4723/wd/hub";
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/test/devices/capabilities/AndroidDevicesCapabilities.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.test.devices.capabilities;
2 |
3 | import org.openqa.selenium.remote.DesiredCapabilities;
4 | import br.com.appium.teste.test.utils.Utils;
5 |
6 | import java.io.File;
7 |
8 | public enum AndroidDevicesCapabilities {
9 |
10 |
11 | ANDROID_OREO_DEV("capabilities/android-oreo-dev.json"),
12 | ANDROID_FISICO("capabilities/android-fisico.json");
13 |
14 |
15 | private String path;
16 |
17 | AndroidDevicesCapabilities(String path) {
18 | this.path = path;
19 | }
20 |
21 | public DesiredCapabilities getAndroidCapabilitiesFromPlataform() {
22 | DesiredCapabilities androidCapabilities = Utils.pathToDesiredCapabilitites(this.path);
23 | androidCapabilities.setCapability("app", new File("apps/Appium.apk").getAbsolutePath());
24 | return androidCapabilities;
25 | }
26 |
27 | public static void showAvaliableAndroidDevices() {
28 | System.out.println("======= ANDROID DEVICES ====== ");
29 | for (AndroidDevicesCapabilities androidDevicesCapabilities : AndroidDevicesCapabilities.values()) {
30 | System.out.println(androidDevicesCapabilities.name());
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/test/devices/capabilities/IOSDevicesCapabilities.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.test.devices.capabilities;
2 |
3 | import org.openqa.selenium.remote.DesiredCapabilities;
4 | import br.com.appium.teste.test.utils.Utils;
5 |
6 | import java.io.File;
7 |
8 | public enum IOSDevicesCapabilities {
9 |
10 | IPHONE_8_DEV("capabilities/iphone-8-dev.json"),
11 | IPHONE_FISICO("capabilities/iphone-fisico.json");
12 |
13 | private String path;
14 |
15 | IOSDevicesCapabilities(String path) {
16 | this.path = path;
17 | }
18 |
19 | public DesiredCapabilities getIOSCapabilitiesFromPlataform() {
20 | DesiredCapabilities iosCapabilities = Utils.pathToDesiredCapabilitites(this.path);
21 | iosCapabilities.setCapability("app", new File("apps/Appium.app").getAbsolutePath());
22 | return iosCapabilities;
23 | }
24 |
25 | public static void showAvaliableIphoneDevices() {
26 | System.out.println("======= IOS DEVICES ====== ");
27 | for (IOSDevicesCapabilities iosDevicesCapabilities : IOSDevicesCapabilities.values()) {
28 | System.out.println(iosDevicesCapabilities.name());
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/test/utils/Commons.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.test.utils;
2 |
3 | import br.com.appium.teste.screens.base.BaseScreen;
4 | import io.appium.java_client.MobileElement;
5 | import io.appium.java_client.TouchAction;
6 | import org.openqa.selenium.JavascriptExecutor;
7 | import org.openqa.selenium.remote.RemoteWebElement;
8 |
9 | import java.util.HashMap;
10 |
11 | public class Commons extends BaseScreen {
12 |
13 | public static void scroll(int startX, int startY, int endX, int endY) {
14 | new TouchAction(DriverFactoryManager.getDriver()).press(startX, startY).waitAction().moveTo(endX, endY).release().waitAction().perform();
15 | }
16 |
17 | public static void holdElement(MobileElement mobileElement) {
18 | new TouchAction(DriverFactoryManager.getDriver()).longPress(mobileElement).perform();
19 | }
20 |
21 | public static void holdElementiOS(MobileElement element) {
22 | JavascriptExecutor js = (JavascriptExecutor) DriverFactoryManager.getDriver();
23 | HashMap
tapObject = new HashMap();
24 | tapObject.put("element", ((RemoteWebElement) element).getId());
25 | tapObject.put("duration", "2");
26 | js.executeScript("mobile: touchAndHold", tapObject);
27 | }
28 |
29 | public static void swipeiOS() {
30 | JavascriptExecutor js = (JavascriptExecutor) DriverFactoryManager.getDriver();
31 | HashMap scrollObject = new HashMap();
32 | scrollObject.put("direction", "up");
33 | js.executeScript("mobile: swipe", scrollObject);
34 | }
35 |
36 | public static void swipeInvertiOS() {
37 | JavascriptExecutor js = (JavascriptExecutor) DriverFactoryManager.getDriver();
38 | HashMap scrollObject = new HashMap();
39 | scrollObject.put("direction", "down");
40 | js.executeScript("mobile: swipe", scrollObject);
41 | }
42 |
43 | public static void dataPicker(MobileElement element) {
44 | JavascriptExecutor js = (JavascriptExecutor) DriverFactoryManager.getDriver();
45 | HashMap picker = new HashMap();
46 | picker.put("order", "next");
47 | picker.put("offset", "0.15");
48 | picker.put("element", ((RemoteWebElement) element).getId());
49 | js.executeScript("mobile: selectPickerWheelValue", picker);
50 | }
51 |
52 | public static void swipe() {
53 | new TouchAction(DriverFactoryManager.getDriver()).press(300, 1000).waitAction().moveTo(300, 50).release().perform();
54 | }
55 |
56 | public static void swipeInvert() {
57 | new TouchAction(DriverFactoryManager.getDriver()).press(300, 50).waitAction().moveTo(300, 1000).release().perform();
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/test/utils/DriverFactoryManager.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.test.utils;
2 |
3 | import java.net.MalformedURLException;
4 | import java.net.URL;
5 |
6 | import br.com.appium.teste.test.constants.Constants;
7 | import br.com.appium.teste.test.devices.capabilities.AndroidDevicesCapabilities;
8 | import br.com.appium.teste.test.devices.capabilities.IOSDevicesCapabilities;
9 | import io.appium.java_client.AppiumDriver;
10 | import io.appium.java_client.android.AndroidDriver;
11 | import io.appium.java_client.ios.IOSDriver;
12 | import io.appium.java_client.service.local.AppiumDriverLocalService;
13 | import org.openqa.selenium.remote.UnreachableBrowserException;
14 |
15 | public class DriverFactoryManager {
16 |
17 | private static AppiumDriver> appiumDriver;
18 | private static AppiumDriverLocalService service;
19 |
20 |
21 | public static AppiumDriver> startDriverByMavenParameter(String mavenEnvironment) {
22 |
23 | if (appiumDriver == null) {
24 |
25 | try {
26 |
27 | if (mavenEnvironment.contains("ANDROID")) {
28 | appiumDriver = new AndroidDriver<>(new URL(Constants.APPIUM_URL_DEV), AndroidDevicesCapabilities.valueOf(mavenEnvironment).getAndroidCapabilitiesFromPlataform());
29 | } else if (mavenEnvironment.contains("IPHONE")) {
30 | appiumDriver = new IOSDriver<>(new URL(Constants.APPIUM_URL_DEV), IOSDevicesCapabilities.valueOf(mavenEnvironment).getIOSCapabilitiesFromPlataform());
31 | }
32 |
33 | } catch (IllegalArgumentException e) {
34 | System.out.println(" ==== AVISO : Por favor selecionar um dos devices abaixo para executar os testes ==== ");
35 | AndroidDevicesCapabilities.showAvaliableAndroidDevices();
36 | IOSDevicesCapabilities.showAvaliableIphoneDevices();
37 | System.exit(1);
38 | } catch (UnreachableBrowserException e) {
39 | System.out.println(" ==== AVISO : Por favor verifique se foi passado uma url válida para executar os testes ou se já inicializou o Appium. ====");
40 | System.exit(1);
41 | } catch (MalformedURLException e) {
42 | System.out.println(" ==== AVISO : Por favor verifique a url que foi informada para executar os testes. ====");
43 | System.exit(1);
44 | }
45 | }
46 |
47 | return appiumDriver;
48 | }
49 |
50 | public static AppiumDriver> getDriver() {
51 | return appiumDriver;
52 | }
53 |
54 | public static void reLaunchApp() {
55 | if (appiumDriver != null) {
56 | appiumDriver.launchApp();
57 | }
58 | }
59 |
60 | public static void quitDriver() {
61 | if (appiumDriver != null) {
62 | appiumDriver.quit();
63 | }
64 | }
65 |
66 | public static String getPageHierarchy() {
67 | return appiumDriver.getPageSource();
68 | }
69 |
70 | public static void appiumServerUp() {
71 | service = AppiumDriverLocalService.buildDefaultService();
72 | service.start();
73 | }
74 |
75 |
76 | public static void appiumServerDown() {
77 | service = AppiumDriverLocalService.buildDefaultService();
78 | service.stop();
79 | }
80 | }
81 |
82 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/test/utils/Print.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.test.utils;
2 |
3 | import cucumber.api.Scenario;
4 | import org.apache.commons.io.FileUtils;
5 | import org.openqa.selenium.OutputType;
6 | import org.openqa.selenium.TakesScreenshot;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 |
11 | public class Print {
12 |
13 | public static void takeScreenShot(Scenario scenario) {
14 |
15 | File scrFile = ((TakesScreenshot) DriverFactoryManager.getDriver()).getScreenshotAs(OutputType.FILE);
16 |
17 | try {
18 | FileUtils.copyFile(scrFile, (new File("./evidence", scenario.getName() + " - " + scenario.getStatus().toUpperCase() + ".png")));
19 | } catch (IOException e) {
20 | e.printStackTrace();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/appium-java/appium-maven/src/test/java/br/com/appium/teste/test/utils/Utils.java:
--------------------------------------------------------------------------------
1 | package br.com.appium.teste.test.utils;
2 |
3 | import java.io.FileReader;
4 | import java.lang.reflect.Type;
5 | import java.util.Map;
6 |
7 | import org.openqa.selenium.remote.DesiredCapabilities;
8 | import com.google.gson.Gson;
9 | import com.google.gson.reflect.TypeToken;
10 |
11 | public class Utils {
12 |
13 | public static DesiredCapabilities pathToDesiredCapabilitites(String path) {
14 | try {
15 | Gson gson = new Gson();
16 | Type type = new TypeToken