mirror of https://github.com/OpenVidu/openvidu.git
ov-components: (test) Enhance element counting method to handle timeouts gracefully
parent
8d1c2468f5
commit
61a3589dd7
|
@ -681,8 +681,8 @@ describe('Stream UI controls and interaction features', () => {
|
||||||
|
|
||||||
await browser.switchTo().window(tabs[0]);
|
await browser.switchTo().window(tabs[0]);
|
||||||
|
|
||||||
await utils.waitForElement('.OV_stream.remote.speaking');
|
|
||||||
expect(await utils.getNumberOfElements('.OV_stream.remote.speaking')).toEqual(1);
|
expect(await utils.getNumberOfElements('.OV_stream.remote.speaking')).toEqual(1);
|
||||||
|
// Wait for at least one speaking element to appear before asserting
|
||||||
expect(await utils.getNumberOfElements('.OV_stream.speaking')).toEqual(1);
|
expect(await utils.getNumberOfElements('.OV_stream.speaking')).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,13 @@ export class OpenViduComponentsPO {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getNumberOfElements(selector: string): Promise<number> {
|
async getNumberOfElements(selector: string, timeout: number = this.TIMEOUT): Promise<number> {
|
||||||
|
try {
|
||||||
|
await this.waitForElement(selector);
|
||||||
|
} catch {
|
||||||
|
// If timeout, return 0 as no elements found
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return (await this.browser.findElements(By.css(selector))).length;
|
return (await this.browser.findElements(By.css(selector))).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue