This automation created using POM design pattern. What is POM? POM stands for Page Object Model. POM is a design pattern used to make automation. Where each page an application or website is used as its own class. This gives an advantage when one of a page's interface changes, then other classes will not be affected.
Then for Scenario scripting, we will use Cucumber and Gherkin.
What is Cucumber? What is Gherkin?
Cucumber is a tool that supports BDD (Behavior-Driven Development).
Gherkin is a set of grammar rules that makes plain text structured enough to be understood by Cucumber. Scenario scripts are written using Gherkin.
Reference: https://docs.cucumber.io/docs/guides/overview/
| Factor | Item |
|---|---|
| Editor | Intellij IDEA Community (https://www.jetbrains.com/idea/download/#section=mac) |
| JDK | JDK 8 (https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html) |
| SDK | Android SDK (https://developer.android.com/studio/archive) |
| Tools | Node.js (https://nodejs.org/dist/latest/) |
| Device | Real device or emulator |
| Dependencies | artifactId: selenium-java, groupId: org.seleniumhq.selenium artifactId: selenium-api, groupId: org.seleniumhq.seleniumartifactId: cucumber-junit, groupId: info.cukesartifactId: cucumber-java, groupId: info.cukesartifactId: cucumber-core, groupId: info.cukesartifactId: gherkin, groupId: info.cukesartifactId: java-client, groupId: io-appiumartifactId: testng, groupId: org.testng |
Install Editor Intellij Idea Community, SDK, Tools, and JDK in computer.
- Run terminal or command prompt
- Type
npm install -g appium - Enter
- Run terminal
- Type
sudo npm install -g appium --unsafe-perm=true --allow-root - Enter
- Right-click My Computer > Properties > Advance system settings > Environment Variables > PATH > Edit
- Type
C:\Java\java-8\bin - Click Save
- Right-click My Computer > Properties > Advance system settings > Environment Variables > PATH > Edit
- Type
C:\Android\Android-sdk\tools;C:\Android\Android-sdk\platform-tools;> Save - Create new variable
ANDROID_HOMEthen type:C:\Android\Android-sdk> Save
Automatically set itself
-
Run Terminal.
-
For Mac: Ketikkan
sudo nano ~/.zhrcFor Mac OS:sudo nano ~/.bash_profile -
On top row type
export ANDROID_HOME=/Users/itworker/Library/Android/sdk export PATH="${ANDROID_HOME}/tools:${PATH}" export PATH="${ANDROID_HOME}/emulator:${PATH}" export PATH="${ANDROID_HOME}/platform-tools:${PATH}"Path depend user computer.
-
Then save
Clone this repository using this command https://github.com/Ebrahim-Mostafa/TrustWalletAutomation.git in terminal or command prompt.
Open this automation using Intellij IDEA.
- Click File > Project Structure
- Make sure JDK 8 is selected in Project SDK
- Search using keyword
cucumber for java - Click Install
- Repeat cucumber.steps 1-2 for plugin
gherkin
|-- test
|-- java
|-- pages
|-- setups
|-- cucumber.steps
|-- resources
|-- features
pagespackage for all page classes.setupspackage for all automation configuration.cucumber.stepspackage for all page step definitions.resourcespackage for all features or non java classes.
For running the automation, we can open scenario file. For example, we will run WelcomeTest scenarios:
- Open
WelcomeTest.java class - Right click one of scenario, then click Run.
- Run from the terminal by using the following command
mvn clean test:mvn clean test -Dfile=testNG.xml
mvn clean test -Dfile=CucumberTestRunner.xml - Run from IntelliJ by adding testNG.xml file to the project configuration runner.
Open your windows PowerShell:
One of the easiest ways to start PowerShell in Windows is using the Run window. Press Win + R keys on your keyboard, then type PowerShell and press Enter or click OK.
Run these Commands:
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
In the above case, it was already installed, so you a message as 'Scoop is already installed'. You can run 'scoop update' to get the latest version any time, To install Allure, using Scoop, run the below command:
scoop install allure
brew install allure
allure serve target/allure-results