Mobile App
The Test Evolve Mobile App driver is available if you have configured test_types in config.yml to include mobile_app
or selected the test_type mobile_app
in Test Evolve Studio.
- Ruby
- JavaScript
- TypeScript
TestEvolve.mobile_app
In Spark Ruby TestEvolve.mobile_app is an instance of a Selenium::WebDriver::Driver.
testEvolve.mobileApp
In Spark JS TestEvolve.mobileApp is an instance of selenium ThenableWebDriver.
testEvolve.mobileApp
Type ThenableWebDriver
imported from "selenium-webdriver"
Elements
Locating Elements
Spark uses native selenium commands to locate elements as shown below:
- Ruby
- JavaScript
- TypeScript
test_evolve.mobile_app.find_element(id: 'unique-identifier')
testEvolve.mobileApp.findElement({ xpath: '//android.widget.Button[@content-desc="alert-trigger-button"]' });
testEvolve.mobileApp.findElement({ xpath: '//android.widget.Button[@content-desc="alert-trigger-button"]' });
All elements are instances of or subclasses of BrowserElement
imported from "@testevolve/testevolve-spark"
Click
- Ruby
- JavaScript
- TypeScript
action.click(element).perform
await element.click();
await element.click();
Send Keys
- Ruby
- JavaScript
- TypeScript
element.type 'value'
await element.sendKeys("value");
await element.sendKeys("value");
Get Text
- Ruby
- JavaScript
- TypeScript
element.text
await element.getText();
await element.getText();
// returns a String
Scroll to Element
- Ruby
- JavaScript
- TypeScript
Documentation to be added
await testEvolve.mobileApp.driver.executeScript("mobile: scroll", { strategy: "accessibility id", selector: "unique-identifier" });
await testEvolve.mobileApp.driver.executeScript("mobile: scroll", { strategy: "accessibility id", selector: "unique-identifier" });
Screen Object
The Mobile App Screen Object model is used as an equivalent to the page object model in the browser. It reduces code duplication and improves test maintenance.
In Spark page object files are generally kept in features/support/screens
.
The following is a basic screen object template:
- Ruby
- JavaScript
- TypeScript
module Screens
def main_screen
@main_screen ||= MainScreen.new
end
class MainScreen < TestEvolve::Core::MobileAppScreenObject
element(:standard_button) { { accessibility_id: 'standard-button' } }
def click_standard_button
standard_button.click
end
end
An instance of the MobileAppScreenObject class can be referenced from any Step Definition file using main_page
.
For example:
main_screen.click_standard_button
import { MobileAppScreenObject } from "@testevolve/testevolve-spark";
class MainScreen extends MobileAppScreenObject {
initialise() {
this.standardButton = this.element(() => ({ "accessibilityId": "standard-button" }));
};
clickStandardButton = async () => {
await this.standardButton().click();
};
};
The ScreenObject class file should be exported in features/support/screens/index.js
so it can then be imported and used in any Step Definition file as shown below:
export { default as mainScreen } from './index.screen';
import { mainScreen } from "../support/screens/index";
await mainScreen.clickStandardButton();
import { MobileAppScreenObject } from "@testevolve/testevolve-spark";
import { WebElement } from "selenium-webdriver";
class MainScreen extends MobileAppScreenObject {
standardButton: WebElement;
initialise() {
this.standardButton = this.element(() => ({ "accessibilityId": "standard-button" }));
};
clickStandardButton = async () => {
await this.standardButton().click();
};
};
The ScreenObject class file should be exported in features/support/screens/index.ts
so it can then be imported and used in any Step Definition file as shown below:
export { default as mainScreen } from './index.screen';
import { mainScreen } from "../support/screens/index";
await mainScreen.clickStandardButton();
Visual testing
- Ruby
- JavaScript
- TypeScript
Read the guide of visual testing here.
TestEvolve.mobile_app.visual_check('label')
Not yet implemented
Not yet implemented