Skip to main content
Version: 9.0.0

Adapters

What is an Adapter?

In software development, an adapter serves a similar purpose to its physical counterpart. Just like power sockets in different countries have varying shapes, adapters help bridge the gap. This is especially true when dealing with different technologies or platforms.

If you've traveled to various countries, you might have encountered power sockets with shapes that don't match your device's plug. An adapter allows you to connect your device to these sockets by changing the plug's form.

Test Maker classifies adapters into 3 categories:

  • Web-based
  • Mobile-based
  • Unit-Based

Unit-Based Adapters

Unit-based adapters are designed to interact with various units in your application.

Configuration Example:

// Add your configuration example here for unit-based adapter
import { adapters, Configuration } from "test-maker";

const testMakerLocalConfig: Configuration = {
runner: {
adapters:[
adapters.unit,
]
},
};
export default testMakerLocalConfig;

Unit adapter is using node as a client. It has no visual interface. It's suitable to perform your API rest request.

Web-based Adapter: Playwright

Playwright is a web-based adapter that facilitates browser automation. It supports various browsers and provides powerful automation capabilities.

Configuration Example:

import { adapters, Configuration } from "test-maker";

const testMakerLocalConfig: Configuration = {
runner: {
adapters:[
adapters.playwright,
]
},
};
export default testMakerLocalConfig;

Example 2:

import { PlaywrightAdapterOptions, Configuration } from "test-maker";

const testMakerLocalConfig: Configuration = {
runner: {
adapters: [
{
name: `playwright`,
options: <PlaywrightAdapterOptions>{
default: true,
files: [
"./src/specs/tests/**/*-spec.ts",
],
clients: [
'chrome',
{
name: `safari`,
options: {
features: [`Safari client`],
files: [`./src/specs/browser-tests/*-spec.ts`]
}
}
]
}
}]
}
};

export default testMakerLocalConfig;

Advantages of Playwright

  • Cross-Browser Compatibility: Playwright supports all modern rendering engines, making it easy to automate tests across different browsers like Chromium, Firefox, and WebKit.
  • Concurrent Execution: Playwright allows you to run tests in parallel, significantly reducing the time needed to execute a suite of tests.
  • Multi-Platform Support: Playwright supports major operating systems, including Windows, macOS, and Linux, allowing you to test your applications across different platforms.

Mobile-based Adapter: Appium

Appium is a mobile-based adapter for automating mobile applications, supporting both Android and iOS.

Configuration Example:

adapters: [
{
name: `appium`,
options: {
clients: [
{
name: `android:chrome`,
options: {
"appium:deviceName": `emulator-5556`,
}
}
]
}
}
]

Web-based Adapter: Selenium

Selenium is a web-based adapter commonly used for web automation, known for its popularity and widespread use.

Configuration Example:

// Add your configuration example here for Selenium

SauceLabs Adapter

SauceLabs is a cloud-based service that provides mobile-based testing solutions.

Configuration Example:

// Add your configuration example here for SauceLabs
adapters:[
{
name:`sauceLabs`,
options: {
connectionRetryTimeout: 120000,
connectionRetryCount: 0,
user: /*Saucelabs User*/,
key: /*Saucelabs Key*/,
region: `eu`,
clients: [
{
name: `android:chrome`,
options:{
"appium:deviceName": "Samsung_Galaxy_Tab_S8_real", //real device
"appium:platformVersion": "Android 12",
"sauce:options": {
appiumVersion: "1.22.1"
}
}
}
]
}
}
]

Interface Definitions

By organizing your content with subtitles and Markdown lists, you can enhance the readability and structure of your "Adapters" section. Adjust the

formatting and content as needed to fit your preferences and style guide.

TestMakerAdapterOptions

PropertyTypeDescription
defaultbooleanSet as true for default options.
clientsstring[] | Client[]List of clients or instances for the adapter.
filesstring[]List of files for the adapter.
featuresstring[]List of features for the adapter.
scenariosstring[]List of scenarios for the adapter.
stepsstring[]List of steps for the adapter.

Client Interface

export interface Client extends Record<any, any> {
name: string;
alias?: string;
headless?: boolean;
args?: string[];
executablePath?: string;
options?: {
[key: string]: any;
} & AdapterClientFilter & {
proxy?: {
server: string;
bypass?: string[];
username?: string;
password?: string;
};
device?: Device;
};
}

Device Interface

export interface Device {
'name': string;
'userAgent': string;
'viewport': {
'width': number;
'height': number;
};
'deviceScaleFactor': number;
'isMobile': boolean;
'hasTouch': boolean;
'defaultBrowserType': string;
}

AdapterClientFilter Interface

export interface AdapterClientFilter {
files?: string[];
features?: string[];
scenarios?: string[];
steps?: string[];
}

Devices Type

export type Devices = {
[key in keyof typeof devicesList]: {
'name': string;
'userAgent': string;
'viewport': {
'width': number;
'height': number;
};
'deviceScaleFactor': number;
'isMobile': boolean;
'hasTouch': boolean;
'defaultBrowserType': string;
};
};

Devices List

The list of supported devices can be consulted on the following page: Device List.

PlaywrightAdapterOptions

PropertyTypeDescription
browserobjectBrowser configuration options.
customVersionstringCustom version of Playwright.

AppiumAdapterOptions

PropertyTypeDescription
hoststringAppium server host.
pathstringAppium server path.
portnumberAppium server port.
protocolstringAppium server protocol.
logLevelstringLog level for Appium.
connectionRetryTimeoutnumberConnection retry timeout for Appium.
connectionRetryCountnumberConnection retry count for Appium.
videoobjectVideo recording options.

SeleniumAdapterOptions

PropertyTypeDescription
hoststringSelenium server host.
pathstringSelenium server path.
portnumberSelenium server port.
protocolstringSelenium server protocol.
logLevelstringLog level for Selenium.
connectionRetryTimeoutnumberConnection retry timeout for Selenium.
connectionRetryCountnumberConnection retry count for Selenium.