@@ -23,10 +23,19 @@ export class VideoComponent extends BaseComponent {
2323 */
2424 public async isPaused ( ) : Promise < boolean > {
2525 return this . props . page . evaluate ( ( selector : string ) => {
26- console . log ( 'Evaluating selector in browser context:' , selector ) ; // Logs selector in browser context
27- const xpathResult = document . evaluate ( selector , document , null , XPathResult . FIRST_ORDERED_NODE_TYPE , null ) ;
28- const video = xpathResult . singleNodeValue as HTMLVideoElement | null ;
29- return video . paused ;
26+ const video = document . evaluate (
27+ selector ,
28+ document ,
29+ null ,
30+ XPathResult . FIRST_ORDERED_NODE_TYPE ,
31+ null
32+ ) . singleNodeValue as HTMLVideoElement | null ;
33+
34+ if ( ! video ) {
35+ throw new Error ( `Video element with id "${ selector } " not found` ) ;
36+ }
37+ return video . paused ;
38+
3039 } , this . props . selector ) ;
3140 }
3241
@@ -37,9 +46,10 @@ export class VideoComponent extends BaseComponent {
3746 * timeout - Optional. The maximum time (in milliseconds) to wait for the validation. Defaults to 3000ms if not provided.
3847 * Pass `true` if the video is expected to be playing, or `false` if it is expected to be paused.
3948 */
40- public async validateVideoIsPlaying ( expectedPlaying : boolean , timeout : number = 3000 ) : Promise < void > {
49+ public async validateVideoIsPlaying ( expectedPlaying : boolean , timeout : number = 6000 ) : Promise < void > {
4150 await expect ( async ( ) => {
42- expect ( await this . isPaused ( ) ) . not . toEqual ( expectedPlaying ) ;
51+ const isPaused = await this . isPaused ( ) ;
52+ expect ( isPaused ) . not . toEqual ( expectedPlaying ) ;
4353 } ) . toPass ( { intervals : [ 500 ] , timeout } ) ;
4454 }
4555}
0 commit comments