Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -2472,7 +2472,7 @@ class Playwright extends Helper {
async waitNumberOfVisibleElements(locator, num, sec) {
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
locator = new Locator(locator, 'css');
await this.context;

let waiter;
const context = await this._getContext();
if (locator.isCSS()) {
Expand Down
1 change: 0 additions & 1 deletion lib/helper/Puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,6 @@ class Puppeteer extends Helper {
async waitNumberOfVisibleElements(locator, num, sec) {
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
locator = new Locator(locator, 'css');
await this.context;
let waiter;
const context = await this._getContext();
if (locator.isCSS()) {
Expand Down
5 changes: 5 additions & 0 deletions test/helper/Playwright_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ describe('Playwright', function () {
.then(() => I.waitNumberOfVisibleElements('.title', 2, 3))
.then(() => I.see('Hello'))
.then(() => I.see('World')));

it('should wait for 0 number of visible elements', async () => {
await I.amOnPage('/form/wait_invisible');
await I.waitNumberOfVisibleElements('#step_1', 0);
});
});

describe('#moveCursorTo', () => {
Expand Down
20 changes: 12 additions & 8 deletions test/helper/Puppeteer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,14 @@ describe('Puppeteer', function () {
});

describe('#waitNumberOfVisibleElements', () => {
it('should wait for a specified number of elements on the page', () => I.amOnPage('/info')
.then(() => I.waitNumberOfVisibleElements('//div[@id = "grab-multiple"]//a', 3))
.then(() => I.waitNumberOfVisibleElements('//div[@id = "grab-multiple"]//a', 2, 0.1))
.then(() => {
throw Error('It should never get this far');
})
.catch((e) => {
it('should wait for a specified number of elements on the page', async () => {
try {
await I.amOnPage('/info');
await I.waitNumberOfVisibleElements('//div[@id = "grab-multiple"]//a', 3);
} catch (e) {
e.message.should.include('The number of elements (//div[@id = "grab-multiple"]//a) is not 2 after 0.1 sec');
}));
}
});

it('should wait for a specified number of elements on the page using a css selector', () => I.amOnPage('/info')
.then(() => I.waitNumberOfVisibleElements('#grab-multiple > a', 3))
Expand All @@ -217,6 +216,11 @@ describe('Puppeteer', function () {
.then(() => I.waitNumberOfVisibleElements('.title', 2, 3))
.then(() => I.see('Hello'))
.then(() => I.see('World')));

it('should wait for 0 number of visible elements', async () => {
await I.amOnPage('/form/wait_invisible');
await I.waitNumberOfVisibleElements('#step_1', 0);
});
});

describe('#moveCursorTo', () => {
Expand Down
5 changes: 5 additions & 0 deletions test/helper/WebDriver_devtools_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,11 @@ describe('WebDriver - Devtools Protocol', function () {
.then(() => wd.see('Hello'))
.then(() => wd.see('World'));
});

it('should wait for 0 number of visible elements', async () => {
await wd.amOnPage('/form/wait_invisible');
await wd.waitNumberOfVisibleElements('#step_1', 0);
});
});

describe('#waitForVisible', () => {
Expand Down