What is @wdio/appium-service?
@wdio/appium-service is a WebdriverIO service that helps you run Appium seamlessly when running your WebdriverIO tests. It simplifies the process of starting and stopping the Appium server, making it easier to manage mobile testing environments.
What are @wdio/appium-service's main functionalities?
Starting Appium Server
This code sample demonstrates how to start an Appium server using WebdriverIO with the @wdio/appium-service. It sets up the desired capabilities for an Android device and starts a session.
const { remote } = require('webdriverio');
const opts = {
path: '/wd/hub',
port: 4723,
capabilities: {
platformName: 'Android',
platformVersion: '9',
deviceName: 'emulator-5554',
app: '/path/to/the/app.apk',
automationName: 'UiAutomator2'
}
};
(async () => {
const client = await remote(opts);
await client.deleteSession();
})();
Stopping Appium Server
This code sample shows how to stop the Appium server after the test session ends. The @wdio/appium-service handles the stopping of the server automatically when the session is deleted.
const { remote } = require('webdriverio');
const opts = {
path: '/wd/hub',
port: 4723,
capabilities: {
platformName: 'Android',
platformVersion: '9',
deviceName: 'emulator-5554',
app: '/path/to/the/app.apk',
automationName: 'UiAutomator2'
}
};
(async () => {
const client = await remote(opts);
await client.deleteSession();
// Appium server will stop automatically after the session ends
})();
Custom Appium Server Arguments
This code sample demonstrates how to pass custom arguments to the Appium server using the @wdio/appium-service. It configures the server to run on a specific address and port, and to log output to a file.
const { remote } = require('webdriverio');
const opts = {
path: '/wd/hub',
port: 4723,
capabilities: {
platformName: 'Android',
platformVersion: '9',
deviceName: 'emulator-5554',
app: '/path/to/the/app.apk',
automationName: 'UiAutomator2'
},
services: [['appium', {
args: {
address: '127.0.0.1',
port: 4723,
log: './appium.log'
}
}]]
};
(async () => {
const client = await remote(opts);
await client.deleteSession();
})();
Other packages similar to @wdio/appium-service
appium
Appium is an open-source tool for automating mobile applications. It allows you to write tests for multiple platforms (iOS, Android) using the same API. Compared to @wdio/appium-service, Appium is the core server that @wdio/appium-service interacts with to manage mobile testing.
wdio-selenium-standalone-service
The wdio-selenium-standalone-service is a WebdriverIO service that helps you run a standalone Selenium server seamlessly when running your WebdriverIO tests. It is similar to @wdio/appium-service but is used for web browser automation instead of mobile app automation.
webdriverio
WebdriverIO is a popular testing framework for Node.js that allows you to write and run tests for web and mobile applications. While WebdriverIO provides the framework and API for writing tests, @wdio/appium-service specifically helps manage the Appium server for mobile testing.
WebdriverIO Appium Service
Handling the Appium server is out of scope of the actual WebdriverIO project. This service helps you to run the Appium server seamlessly when running tests with the WDIO testrunner. It starts the Appium Server in in a child process.
Installation
The easiest way is to keep @wdio/appium-service
as a devDependency in your package.json
.
{
"devDependencies": {
"@wdio/appium-service": "^5.0.0"
}
}
You can simple do it by:
npm install @wdio/appium-service --save-dev
Instructions on how to install WebdriverIO
can be found here.
Configuration
In order to use the service you need to add appium
to your service array:
export.config = {
services: ['appium'],
};
Options
The following options can be added to the wdio.conf.js file.
logPath
Path where all logs from the Appium server should be stored.
Type: String
Default: {}
Example:
export.config = {
appium: {
logPath : "./",
}
}
command
The name of the command which should be started.
Type: String
Default: {}
Example:
export.config = {
appium: {
command: "myAppium",
}
}
args
Map of arguments for the Appium server, passed directly to appium
.
See the documentation for possible arguments.
The arguments should be supplied in lower camel case, so --pre-launch true
becomes preLaunch: true
.
Type: Object
Default: {}
Example:
export.config = {
appium: {
args: {
debugLogSpacing: true,
platformName: 'iOS',
}
}
},
For more information on WebdriverIO see the homepage.