Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@wdio/globals
Advanced tools
@wdio/globals is a package that provides global variables and functions for WebdriverIO, a popular automation test framework. It simplifies the setup and usage of WebdriverIO by offering a set of globally accessible utilities.
Global Browser Object
The global `browser` object allows you to interact with the browser instance directly. This includes navigating to URLs, interacting with elements, and more.
browser.url('https://example.com');
Global Expect Function
The global `expect` function is used for assertions in your tests. It allows you to make assertions about the state of the browser or elements within it.
expect(browser).toHaveTitle('Example Domain');
Global $ and $$ Functions
The global `$` and `$$` functions are shorthand for selecting single and multiple elements, respectively. They simplify the process of element selection in your tests.
const element = $('selector'); const elements = $$('selector');
Selenium WebDriver is a widely-used tool for browser automation. It provides a more low-level API compared to WebdriverIO, requiring more boilerplate code to achieve similar tasks.
Cypress is an end-to-end testing framework that offers a more developer-friendly experience with automatic waiting and a more intuitive API. However, it is limited to testing within the browser and does not support multiple browser instances.
Nightwatch.js is an end-to-end testing framework built on top of Selenium WebDriver. It provides a higher-level API compared to Selenium WebDriver but is not as feature-rich or user-friendly as WebdriverIO.
A helper utility for importing global variables directly
In your test files, WebdriverIO puts each of these methods and objects into the global environment. You don't have to import anything to use them. However, if you prefer explicit imports, you can do import { browser, $, $$, expect } from '@wdio/globals'
and set injectGlobals: false
in your WDIO configuration.
The following global objects are set if not configured otherwise:
browser
: WebdriverIO Browser objectdriver
: alias to browser (used when running mobile tests)multiremotebrowser
: alias to browser or driver but only set for Multiremote sessions$
: command to fetch an element (see more in API docs)$$
: command to fetch elements (see more in API docs)expect
: assertion framework for WebdriverIO (see API docs)Note: WebdriverIO has no control of used frameworks (e.g. Mocha or Jasmine) setting global variables when bootstrapping their environment.
To install the package, run:
npm i @wdio/globals --save-dev
You can implicitly import WebdriverIO primitives as following:
import { browser, $, $$, expect } from '@wdio/globals'
describe('my test', () => {
// ...
it('can do something', async () => {
// ...
})
// ...
})
If you have a TypeScript project you can propagate the WebdriverIO namespace by adding this package to the types
list, e.g.:
{
"compilerOptions": {
"types": ["node", "@wdio/globals/types"]
}
}
For more information on WebdriverIO Globals, check out the docs.
v9.1.3 (2024-10-08)
wdio-browser-runner
, wdio-logger
, webdriverio
webdriverio
wdio-sauce-service
, wdio-spec-reporter
webdriverio
webdriver
wdio-browser-runner
FAQs
A helper utility for importing global variables directly
The npm package @wdio/globals receives a total of 434,174 weekly downloads. As such, @wdio/globals popularity was classified as popular.
We found that @wdio/globals demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.