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

Unit-Based Adapters

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

Code Example (Configuration):

// 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 client. It has no visual interface. It's suite to perform your API rest request.

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

const configuration: Configuration = {
runner:{
adapters: [
adapters.unit
]
}
};

export default configuration;

Playwright

Web-based Adapter

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

Code Example (Configuration):

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;
export interface PlaywrightAdapterOptions extends TestMakerAdapterOptions {
browser?: {
launch?: {
timeout?: number;
};
};
customVersion?: string;
}

You can use aliases for your browser clients, allowing you to run several instances of the same browser, providing flexibility. For example:

       {
name: `playwright`,
options: <PlaywrightAdapterOptions>{
default: true,
clients: [
'chrome',
{
name: `chrome`,
alias: `alias1`,
},
{
name: `chrome`,
alias: `alias2`,
},
],
}
},

Playwright is a powerful open-source testing framework developed by Microsoft that enables browser automation for Chromium, Firefox, and WebKit-based web browsers. It allows you to automate browser actions, interactions, and testing scenarios in a unified and consistent way across different browsers.

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.

How to use different web browsers ?

In Test Maker, you can easily configure and use different web browsers for running your tests. This provides flexibility in testing across various browser environments. Here's how you can set this up in your configuration file:

Configuration

Within the runner options, you can specify the adapters for different browsers using the adapters option:

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

const configuration: Configuration = {
runner:{
adapters: [
{
name: "playwright",
options: <PlaywrightAdapterOptions>{
clients: [
"chrome",
"firefox",
"safari",
// "edge", Chromium-based like Chrome
// "brave", Chromium-based like Chrome
]
}
}
]
}
};

export default configuration;

In this example, we've included adapters for various browsers including Chromium-based browsers, Firefox, and Safari.

Supported Browsers

Chromium based browsers

chromium

Firefox (Nightly) browser

Firefox

Safari(Webkit)

Safari

You can refer to Playwright's list of supported clients to explore more supported browsers.

Appium

Mobile-based Adapter

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

Code Example (Configuration):

adapters: [
{
name: `appium`,
options: {
clients: [
{
name: `android:chrome`,
options: {
"appium:deviceName": `emulator-5556`,
}
}
]
}
}
]
import { TestMakerAdapterOptions } from '../test-maker-adapter-options';

export interface AppiumAdapterOptions extends TestMakerAdapterOptions {
host?: string;
path?: string;
port?: number;
protocol?: string;
logLevel?: string;
connectionRetryTimeout?: number;
connectionRetryCount?: number;
video?: {
enabled?: boolean;
path?: string;
};
}

Appium is an open-source automation tool for mobile applications on Android and iOS platforms. It allows you to automate interactions with mobile apps, test them on real devices, emulators, or simulators.

 adapters: [
{
name: `appium`,
options: {
clients: [
{
name: `android:chrome`,
options: {
"appium:deviceName": `emulator-5556`
}
},
{
name: `ios:safari`,
options: {
"appium:deviceName": `iPhone 13 Pro Max`
}
}
]
}
}
]

Selenium

Web-based Adapter

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

Code Example (Configuration):

// Add your configuration example here for Selenium
import { Client } from "../client/client";
import { AdapterClientFilter } from "./adapter-client-filter";

export interface SeleniumAdapterOptions extends TestMakerAdapterOptions {
host?: string;
path?: string;
port?: number;
protocol?: string;
logLevel?: string;
connectionRetryTimeout?: number;
connectionRetryCount?: number;
}

Selenium is a widely used open-source tool for automating web browsers. It allows you to automate web applications for testing purposes but is not limited to just that. You can also perform tasks like screen scraping, automating repetitive tasks, etc.

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

const configuration: Configuration = {
runner: {
adapters: [adapters.selenium]
}
};

export default configuration;

SauceLabs

Mobile-based Adapter

Web-based Adapter

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

Code Example (Configuration):

// 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

TestMakerAdapterOptions

PropertyTypeDescription
defaultbooleanSet as true for default options.
clientsstring[]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.

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.