Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
testcafe-browser-tools
Advanced tools
An utility library for performing platform-dependent actions on browsers.
The testcafe-browser-tools npm package provides a set of tools for interacting with and controlling web browsers. It is primarily used in conjunction with TestCafe, a popular end-to-end testing framework, to perform various browser-related tasks such as taking screenshots, resizing windows, and more.
Take Screenshot
This feature allows you to take a screenshot of the current browser window. The `takeScreenshot` function accepts an options object where you can specify the path to save the screenshot and whether to capture the full page.
const browserTools = require('testcafe-browser-tools');
browserTools.takeScreenshot({
path: 'screenshot.png',
fullPage: true
}).then(() => {
console.log('Screenshot taken');
}).catch(err => {
console.error('Error taking screenshot:', err);
});
Resize Window
This feature allows you to resize the browser window to specified dimensions. The `resize` function accepts an options object where you can specify the width and height of the window.
const browserTools = require('testcafe-browser-tools');
browserTools.resize({
width: 1024,
height: 768
}).then(() => {
console.log('Window resized');
}).catch(err => {
console.error('Error resizing window:', err);
});
Close Browser
This feature allows you to close the current browser window. The `close` function does not require any parameters and returns a promise that resolves when the browser is closed.
const browserTools = require('testcafe-browser-tools');
browserTools.close().then(() => {
console.log('Browser closed');
}).catch(err => {
console.error('Error closing browser:', err);
});
Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. It can be used for taking screenshots, generating PDFs, and automating form submissions, among other things. Compared to testcafe-browser-tools, Puppeteer offers more comprehensive browser automation capabilities but is more complex to set up and use.
Selenium WebDriver is a popular tool for automating web applications for testing purposes. It supports multiple browsers and programming languages. While it offers extensive browser control and automation features similar to testcafe-browser-tools, it is generally more complex and requires a Selenium server to run.
Nightwatch is an end-to-end testing framework that uses the W3C WebDriver API to interact with browsers. It provides a simple syntax for writing tests and includes built-in support for running tests in parallel. Compared to testcafe-browser-tools, Nightwatch is more focused on testing and less on general browser control.
TestСafe Browser Tools is an utility library for performing platform-dependent actions on browser windows. Working with browsers is specific for each operating system and requires native code to deal with. In order to provide painless and simple installation, this package encapsulates pre-built binaries for all supported platforms and JS-wrappers around them. This helps end-users avoid running post-npm-install build actions.
To build native binaries from source files, execute the gulp task corresponding to your operating system:
'buildWin'
'buildMac'
'buildLinux'
Important note: The application for a particular platform must be built on a machine with the same platform. Since this package can be used on old OS version such as NodeJS 16 docker container, it is important to build binaries on the old OS version for the binaries to contain corresponding dependencies(for example glibc-2.31 for node16 docker image).
The bin directory contains pre-built native binaries. Consider using them if your contribution does not affect the native modules.
$ npm install testcafe-browser-tools
Important note: To identify the web browser window, most of the provided functions use its title.
This title matches the web page's document.title
in most of the browsers.
However, Microsoft Edge truncates the window title to the hostname if document.title
contains only a URL
( e.g. document.title = 'http://localhost:1337/page'
gives localhost
in the window title).
So, you need to add some characters before the URL in order to bring it to the window title:
document.title = 'title: ' + document.location.toString()
For API reference, see the API document.
To run automated tests:
$ npm test
Since the module functionality depends on browsers available on a testing machine and you cannot predict expected returned values for some functions, the automated tests cover only a part of the functionality. To test all the functions provided by the module, use the playground. To run it, execute the gulp task corresponding to your operating system:
$ gulp runPlaygroundWin
$ gulp runPlaygroundMac
$ gulp runPlaygroundLinux
This will open the Playground web page at http://localhost:1334/, where you can manually check if the functions work correctly.
Developer Express Inc.(http://devexpress.com)
FAQs
An utility library for performing platform-dependent actions on browsers.
The npm package testcafe-browser-tools receives a total of 147,462 weekly downloads. As such, testcafe-browser-tools popularity was classified as popular.
We found that testcafe-browser-tools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.