Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@wdio/shared-store-service
Advanced tools
@wdio/shared-store-service is a service for WebdriverIO that allows you to share data between different browser sessions and processes. This can be particularly useful for end-to-end testing scenarios where you need to maintain state or share information across different test runs.
Set Data in Shared Store
This feature allows you to set a key-value pair in the shared store. The data can then be accessed by other browser sessions or processes.
await browser.sharedStore.set('key', 'value');
Get Data from Shared Store
This feature allows you to retrieve a value from the shared store using a key. This is useful for accessing data that was set in a different session or process.
const value = await browser.sharedStore.get('key');
Delete Data from Shared Store
This feature allows you to delete a key-value pair from the shared store. This can be useful for cleaning up data after tests have run.
await browser.sharedStore.delete('key');
WebdriverIO is a popular testing framework for Node.js. While it does not have built-in shared store functionality, it offers a wide range of plugins and services that can be used to extend its capabilities, including state management and data sharing.
Selenium WebDriver is a widely-used tool for automating web applications. It does not natively support shared stores, but you can implement similar functionality using external storage solutions like Redis or a database.
Cypress is an end-to-end testing framework that offers a different approach to testing compared to WebdriverIO. While it does not have a built-in shared store, it provides various ways to manage state and share data between tests, such as using environment variables or custom commands.
Exchange data between main process and workers (specs).
The easiest way is to keep @wdio/shared-store-service
as a dev dependency in your package.json
, via:
npm install @wdio/shared-store-service --save-dev
Instructions on how to install WebdriverIO
can be found here.
Get/set a value (a plain object) to/from the store by key (string). The key can be any arbitrary string except *
which is reserved as it allows you to fetch the whole store.
To set values to the store call:
await browser.sharedStore.set('key', 'foobar123')
To get values from the store call:
const value = await browser.sharedStore.get('key')
console.log(value) // returns "foobar123"
You can also fetch all key values by using the *
key:
const store = await browser.sharedStore.get('*')
console.log(value) // returns `{ key: "foobar" }`
You could also directly access to setValue
and getValue
async handlers.
Make sure you properly call them with the await
keyword.
// wdio.conf.js
import { setValue, getValue } from '@wdio/shared-store-service'
export const config = {
// ...
onPrepare: [async function (config, capabilities) {
await setValue('foo', 'bar')
}],
// ...
after: async () => {
const value = await getValue('foo')
// ...
}
IMPORTANT! Every spec file should be atomic and isolated from others' specs. The idea of the service is to deal with very specific environment setup issues. Please avoid sharing test execution data!
If the worker threads are competing for resources that must be assigned for each worker, you can use Resource Pool API:
// wdio.conf.js
import { setResourcePool, getValueFromPool, addValueToPool } from '@wdio/shared-store-service'
export const config = {
maxInstances: 2,
// ...
onPrepare: async function (config, capabilities) {
await setResourcePool('availableUrls', ['url01.com', 'url02.com'])
},
// ...
beforeSession: async (conf) => {
conf.baseUrl = await getValueFromPool('availableUrls');
},
// ...
afterSession: async (conf) => {
// worker returns the used resource for next workers to use
await addValueToPool('availableUrls', conf.baseUrl);
}
This example ensures that both workers never use the same baseUrl
. A unique url is only assigned to one worker until it's released by it.
Add shared-store
to the services list and the sharedStore
object will be accessible to you on the browser
scope in your test.
// wdio.conf.js
export const config = {
// ...
services: ['shared-store'],
// ...
};
If you are using typescript, make sure to add @wdio/shared-store-service
to your compilerOptions.types
:
{
"compilerOptions": {
"types": ["node", "@wdio/globals/types", "@wdio/shared-store-service"],
}
}
v9.5.2 (2025-01-09)
webdriverio
wdio-testingbot-service
wdio-appium-service
FAQs
A WebdriverIO service to exchange data across processes
The npm package @wdio/shared-store-service receives a total of 82,813 weekly downloads. As such, @wdio/shared-store-service popularity was classified as popular.
We found that @wdio/shared-store-service 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.