Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
/ device-dealer Public archive

Device management service that helps you to run Appium tests in parallel with real devices in your local lab.

License

Notifications You must be signed in to change notification settings

ochubey/device-dealer

Repository files navigation

License: MIT Codacy Badge Device Dealer icon FOSSA Status

Device-Dealer

Device management service that will help you to run Appium tests in parallel with real devices in your local lab.

Device Dealer example screenshot

Service compilation

Before running service, please update config.properties according to your needs:

Configuration value Purpose
DEVICE_POOL_TIMEOUT=1000 Time in milliseconds to check if device execution state has been changed
BLACK_LIST_BUNDLE_IDS=WebDriverAgentRunner,appium List of comma separated bundle ids of application that need to be removed from the device after it was connected to service
DEVELOPMENT_TEAM=0000000000 Unique id of your team that could be found on https://developer.apple.com/account and needed for execution of Appium tests on real iOS devices. read more.
PRODUCT_BUNDLE_IDENTIFIER=com.facebook.WebDriverAgentRunner Default value of WDA bundle. In some cases need to be updated. read more.
CODE_SIGN_IDENTITY=iPhone Developer Another option that needed for WebDriverAgentRunner to be installed on iOS devices. read more.
USE_EMULATORS=true Flag will tell service if Android Emulators should be ignored during Android devices search in your system.

In order to run service from code execute following command from the root folder of the project:

./gradlew clean bootRun

In order to get distributable .jar file execute following command from the root folder of the project:

./gradlew clean build

Then navigate to /build/libs/ folder and copy dd-<version>.jar file. Jar file can be executed on workstation with JRE using basic command:

java -jar dd-<version>.jar

Device-Dealer usage

Device-Dealer provides information about device via API. Currently there is an Agent for Java based Appium frameworks that provide Appium Server URL by pooling for idle device of specific platform.

In order to establish connection between Device Dealer and Appium Driver, please, use following steps:

  1. add latest device-java-agent dependency to your build file;
  2. use code bellow (snippet#1) to book available device and get Appium Server URL before Driver initialization.

Code snippets

Snippet#1: by default Device Dealer will be executed on localhost:8989 and agent will check for free device 360 times every 10 seconds and if device would not be found - nothing would be returned. Both host and lookup strategy could be changed based on infrastructure needs in further releases.

public class AppiumTest{
    private static Device device;
    private static DeviceDealerAgent deviceDealerAgent = new DeviceDealerAgent();
    
    private void initDriver(String platform) {
        DesiredCapabilities desiredCapabilities = DEVICE_CAPABILITIES.getDesiredCapabilities();
        
        device = deviceDealerAgent.bookDevice(platform);
        assertNotNull("Unable to find free device after 60 minutes or Device Dealer is unreachable", device);
    
        if (platform.equalsIgnoreCase("ios")) {
            driver = new IOSDriver(device.getAppiumServerUrl(), desiredCapabilities) {};
        } else if (platform.equalsIgnoreCase("android")) {
            driver = new AndroidDriver(device.getAppiumServerUrl(), desiredCapabilities) {};
        }
        assert driver != null;
    }
}

In case if non-defaults settings are needed - both service location and pooling frequency/timeout could be changed:

public class AppiumTest{
    //Agent will try to communicate with service with endpoints on 192.168.1.1:9999
    DeviceDealerAgent deviceDealerAgent = new DeviceDealerAgent("192.168.1.1", 9999);
    
    private void initDriver(String platform) {
        //Agent will try to get idle device 10 times every 10 seconds
        deviceDealerAgent.bookDevice(platform, 10, 60000);
    }
}

Initial setup of your system

Presumably your environment is ready for test execution at least on one Android and one iOS device.

Just to make sure that all dependencies and prerequisites are meat - device dealer will check basic configuration of your system. Please follow error messages, if any appear during service execution, and restart service after each issue was resolved.

Xcode

Install latest Xcode either from the Mac App Store or the developer pages Make sure that Xcode is selected and can be used from terminal:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Homebrew

Install homebrew by executing the following in a terminal

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

node.js

Download and install node.js. Make sure node is available on your $PATH.

To install using homebrew run:

brew install node

Other dependencies

Install all locally managed node modules:

npm install

Authorise iOS Instrumentation (needed after Xcode install/update):

npm run authorize-ios

Install ideviceinstaller and carthage for Appium to install application and WDA. Also ios-deploy is needed globally in order to install applications to the real devices.

brew install ideviceinstaller
brew install carthage
npm install -g ios-deploy

Install and configure Android SDK

Download Android SDK and follow installation instructions to configure it. Make sure that your PATH, ANDROID_HOME, JAVA_HOME are properly configured.

Follow instructions from Appium Doctor to configure workstation configuration:

npm run doctor
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

License

FOSSA Status

About

Device management service that helps you to run Appium tests in parallel with real devices in your local lab.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages