Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
expected-condition-playwright
Advanced tools
expected-condition-playwright is a Node.js library with useful expected condition class
expected-condition-playwright is a Node.js library for Playwright and Puppeteer that supplies a set of common conditions that provides functionalities to wait for certain conditions till a defined task is complete.
To use expected-condition-playwright in your project, run:
npm i -D expected-condition-playwright
TypeScript
// Import ExpectedCondition class as EC shortcut
import { ExpectedCondition as EC } from 'expected-condition-playwright';
// Simple selector
const submitButton = 'button';
// Use page's waitForFunction method to provide the elementToBeClickable method to instruct a command to wait until the element is clickable by the selector
await page.waitForFunction(EC.elementToBeClickable(submitButton), submitButton, { timeout: 5000 });
JavaScript
// Require ExpectedCondition class as EC shortcut
const { ExpectedCondition: EC } = require('expected-condition-playwright');
// Simple selector
const submitButton = 'button';
// Use page's waitForFunction method to provide the elementToBeClickable method to instruct a command to wait until the element is clickable by the selector
await page.waitForFunction(EC.elementToBeClickable(submitButton), submitButton, { timeout: 5000 });
An expectation for checking element with given selector has attribute with a specific value
Usage
const inputSelector = 'input[type=q]';
const expectedAttribute = 'type';
const expectedValue = 'q';
await page.waitForFunction(
EC.attributeValueToBe([inputSelector, expectedAttribute, expectedValue]),
[inputSelector, expectedAttribute, expectedValue],
{ timeout: 5000 },
);
An expectation for checking element with given selector has attribute which contains a specific value
Usage
const inputSelector = 'input[type=que]';
const expectedAttribute = 'type';
const expectedValue = 'q';
await page.waitForFunction(
EC.attributeValueContains([inputSelector, expectedAttribute, expectedValue]),
[inputSelector, expectedAttribute, expectedValue],
{ timeout: 5000 },
);
An expectation for checking element with given selector any non empty value for given attribute
Usage
const inputSelector = 'input[type=que]';
const expectedAttribute = 'type';
await page.waitForFunction(
EC.attributeValueContains([inputSelector, expectedAttribute]),
[inputSelector, expectedAttribute],
{ timeout: 5000 },
);
An expectation for checking number of elements with given selector
Usage
const links = 'a';
const expectedNumber = '12';
await page.waitForFunction(EC.numberOfElementsToBe([links, expectedNumber]), [links, expectedNumber], {
timeout: 5000,
});
An expectation for checking the element to be invisible
Usage
const link = 'a';
await page.waitForFunction(EC.invisibilityOf(link), links, { timeout: 5000 });
An expectation for checking if the given text is present in the specified element.
Usage
const logInButton = 'button';
const expectedText = 'Log in';
await page.waitForFunction(EC.textToBePresentInElement([logInButton, expectedText]), [logInButton, expectedText], {
timeout: 5000,
});
An expectation for checking if the given text is present in the specified elements value attribute.
Usage
const userField = 'input';
const expectedValue = 'John';
await page.waitForFunction(EC.textToBePresentInElementValue([userField, expectedValue]), [userField, expectedValue], {
timeout: 5000,
});
An expectation for checking the element is visible and enabled such that you can click it.
Usage
const nextButton = 'button';
await page.waitForFunction(EC.elementToBeClickable(nextButton), nextButton, { timeout: 5000 });
An expectation for checking the element is visible and enabled such that you can click it.
Usage
const checkbox = 'input';
await page.waitForFunction(EC.elementToBeSelected(checkbox), checkbox, { timeout: 5000 });
An expectation for checking the title of a page.
Usage
const expectedTitle = 'Playwright';
await page.waitForFunction(EC.titleEquals(expectedTitle), expectedTitle, { timeout: 5000 });
An expectation for checking that the title contains a case-sensitive substring
Usage
const expectedTitle = 'Play';
await page.waitForFunction(EC.titleContains(expectedTitle), expectedTitle, { timeout: 5000 });
An expectation for the URL of the current page to be a specific url.
Usage
const expectedUrl = 'http://github.com/';
await page.waitForFunction(EC.urlEquals(expectedUrl), expectedUrl, { timeout: 5000 });
An expectation for the URL of the current page to contain specific text.
Usage
const expectedUrl = '.com';
await page.waitForFunction(EC.urlContains(expectedUrl), expectedUrl, { timeout: 5000 });
expected-condition-playwright is MIT licensed.
FAQs
expected-condition-playwright is a Node.js library with useful expected condition class
The npm package expected-condition-playwright receives a total of 422 weekly downloads. As such, expected-condition-playwright popularity was classified as not popular.
We found that expected-condition-playwright demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.