What is @applitools/ufg-client?
@applitools/ufg-client is a client library for Applitools' Ultrafast Grid, which is a cloud-based platform for visual testing and cross-browser testing. It allows developers to capture screenshots of web pages and compare them against a baseline to detect visual differences. The package provides functionalities for setting up tests, capturing screenshots, and managing test results.
What are @applitools/ufg-client's main functionalities?
Setup and Configuration
This code demonstrates how to set up and configure the Visual Grid client with an API key and server URL.
const { makeVisualGridClient } = require('@applitools/ufg-client');
const visualGridClient = makeVisualGridClient({
apiKey: 'YOUR_API_KEY',
serverUrl: 'https://eyesapi.applitools.com',
});
Capture Screenshots
This code demonstrates how to capture a screenshot of a web page using the Visual Grid client. It opens a new test, captures a screenshot of the main page, and then closes the test.
const { makeVisualGridClient } = require('@applitools/ufg-client');
const visualGridClient = makeVisualGridClient({
apiKey: 'YOUR_API_KEY',
});
async function captureScreenshot() {
const eyes = visualGridClient.openEyes({
appName: 'My App',
testName: 'My Test',
});
await eyes.checkWindow({
tag: 'Main Page',
target: 'window',
});
await eyes.close();
}
captureScreenshot();
Manage Test Results
This code demonstrates how to manage test results. It captures a screenshot and then logs the test results to the console.
const { makeVisualGridClient } = require('@applitools/ufg-client');
const visualGridClient = makeVisualGridClient({
apiKey: 'YOUR_API_KEY',
});
async function manageResults() {
const eyes = visualGridClient.openEyes({
appName: 'My App',
testName: 'My Test',
});
await eyes.checkWindow({
tag: 'Main Page',
target: 'window',
});
const results = await eyes.close();
console.log(results);
}
manageResults();
Other packages similar to @applitools/ufg-client
cypress
Cypress is a JavaScript end-to-end testing framework that allows developers to write tests for web applications. It provides functionalities for capturing screenshots and comparing them against a baseline, similar to @applitools/ufg-client. However, Cypress is more focused on functional testing and provides a broader range of testing capabilities beyond visual testing.
webdriverio
WebdriverIO is a JavaScript testing framework that allows developers to write tests for web applications using the WebDriver protocol. It supports visual regression testing through plugins like wdio-visual-regression-service, which can capture screenshots and compare them against a baseline. Compared to @applitools/ufg-client, WebdriverIO provides more flexibility and integration options for different types of testing.
puppeteer
Puppeteer is a Node.js library that provides a high-level API to control headless Chrome or Chromium browsers. It can be used for visual regression testing by capturing screenshots and comparing them against a baseline using additional libraries like pixelmatch. While Puppeteer is not specifically designed for visual testing, it offers powerful browser automation capabilities that can be leveraged for this purpose.