Loading repository data…
Loading repository data…
StevenMedinaBatista / repository
Proyecto de automatizacion en webdriverio, appium, typescript y cucumber
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
<<<<<<< HEAD
(This project was executed with apk, app, ipa generated from) Repository (link)
Mobile, Web and API automation framework based on Cucumber - WebdriverIO - NodeJS - TypeScript - Axios - Allure Reports. With support to execute test on BrowserStack cloud service.
Name : ANDROID_HOME
Value : C:\Users\USERID\AppData\Local\Android\Sdk
Name : JAVA_HOME
Value : C:\Program Files\Java\jdk1.8.0_241
Name : path
Value : C:\Users\USERID\AppData\Local\Android\Sdk\platform-tools
Name : path
Value : C:\Users\USERID\AppData\Local\Android\Sdk\emulator
- Open **Android Studio** and go to: **Tools** -> **AVD Manager** -> **Create Virtual Device...**
- Select **Nexus 6** - > **Next** -> **API Level 10** -> **Next** -> Then rename device as Nexus 6 -> **Finish**.
**List of devices connected**
With this command we can see a list of emualtors available on our local machine.
```
$ emulator -list-avds
```
**Open an emulator**
We can open an emulator with the command **emulator** *@device_name* from the list of devices availables on local machine.
For example:
```
$ emulator @Nexus_6
```
As root or admin.
To install dependencies:
$ npm install
To execute web testing in Chrome
$ npm run start-web
With an emulator open to execute mobile testing on local machine.
$ npm run start-mobile
Exclusive BrowserStack: With user and key of an account and to execute mobile testing. Account's data must be in config file: config\wdio.mobile.bs.conf.ts.
$ npm run start-mobile-bs
$ npm run clean-report
To Open an Allure Report
$ npm run open-report
In this folder we need to have the apk artifact.
We have this files:
Configuration and parameters:
specs: List of cucumber features to execute.
reporters/reporter options: Specifies the reporter to use, we use Allure Report.
host/port/path: Configuration of Appium server.
maxInstances: Maximus instances per execution, by default we must execute with 1 for mobile.
waitforTimeout/connectionRetryTimeout: Parameters to set maximus time out.
capabilities: set of options related to device, platform, device name.
capabilities: (BrowserStack) set of options related to device, platform, device name.
services:
logLevel: We can use debug to log all the actions on appium or silent mode only to log final results.
framework/cucumberOpts: We use Cucumber framework to execute.
List of hooks of Cucumber we use:
IMPORTANT: All hooks must be implemented using async/await.
Examples:
/**
* Runs after a Cucumber step
*/
afterStep: async function () {
await browser.takeScreenshot();
},
/**
* Runs after a Cucumber scenario
*/
afterScenario: async function () {
await browser.closeApp();
await browser.reset();
},
We can use differents hooks, please visit WebDriver IO Hooks for more details.
On this folder we have the list of cucumber .feature files group by functionalities.
On this folder we have the definitions of each view of our application using Page Object Model pattern to define using Typescript.
The basic structure of each POM must have: Filename: viewToModelPO.ts
import Page from './page';
/**
* sub page containing specific selectors and methods for a specific page
*/
class LoginPage extends Page {
/**
* define selectors using getter methods
*/
get inputUsername() { return $('#username') }
get inputPassword() { return $('#password') }
get btnSubmit() { return $('button[type="submit"]') }
/**
* a method to encapsule automation code to interact with the page
* e.g. to login using username and password
*/
async login(username: string, password: string) {
await (await this.inputUsername).setValue(username);
await (await this.inputPassword).setValue(password);
await (await this.btnSubmit).click();
}
/**
* overwrite specifc options to adapt it to page object
*/
open() {
return super.open('login');
}
}
export default new LoginPage();
On this folder we have to create the steps per functionality out set of scenarios defined on our .feature files.
For example: We have an login.feature file with this definition to execute with a set of 2 groups of data:
@run @web
Feature: The Internet Guinea Pig Website
@login_web
Scenario Outline: As a user <username>, I can log into the secure area
Given I am on the login page
When I login with <username> and <password>
Then I should see a flash message saying <message>
Examples:
| username | password | message |
| tomsmith | SuperSecretPassword! | You logged into a secure area! |
| foobar | barfoo | Your username is invalid! |
For each Given, When, Then step we have to create a step to do the behavior that happen on the application.
For example: On our loginSteps.ts file, we will import our pages defined to create a test.
import { Given, Then, When } from '@cucumber/cucumber';
import LoginPage from '../../pages/web/login.page';
import Page from '../../pages/web/page';
import SecurePage from '../../pages/web/secure.page';
const pages: { [key: string]: Page } = { ["login"]: LoginPage };
Given(/^I am on the (\w+) page$/, async (page: string) => {
await pages[page].open();
});
When(/^I login with (\w+) and (.+)$/, async (username: string, password: string) => {
await LoginPage.login(username, password);
});
Then(/^I should see a flash message saying (.*)$/, async (message: string) => {
await expect(SecurePage.flashAlert).toBeExisting();
await expect(SecurePage.flashAlert).toHaveTextContaining(message);
});
On this folder we have a few utility classes for example: constants.ts, utils.ts.
Scripts desctiptions:
clean: Delete all files generated on each execution like reports.start-mobile: with this script we only run the scenarios or features with @run tag. on every .feature file that we have on our wdio ./config/wdio.mobile.config.ts on field specs and have to be releated to the stepDefinition files on cucumberOpts.require from the same config file.start-mobile-bs: *exclusive