| 19 | } |
| 20 | |
| 21 | export async function waitForVideoToLoad(videoLocator: Locator): Promise<void> { |
| 22 | // メタデータが読み込まれれば、動画のサイズが取得できる |
| 23 | await videoLocator.evaluate((video) => { |
| 24 | if (!(video instanceof HTMLVideoElement)) { |
| 25 | throw new Error('Element is not a video'); |
| 26 | } |
| 27 | return new Promise((resolve) => { |
| 28 | if (video.readyState >= 1) { |
| 29 | resolve(null); |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | video.addEventListener('loadedmetadata', () => { |
| 34 | resolve(null); |
| 35 | }); |
| 36 | }); |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | export async function waitForAllImagesToLoad(locator: Locator, expectedNumberOfImages: number = 1): Promise<void> { |
| 41 | const images = locator.locator('img'); |