@@ -2,6 +2,7 @@ import logger from '@wdio/logger'
22import { expect } from '@wdio/globals'
33import { dirname , normalize , resolve } from 'node:path'
44import type { Capabilities , Frameworks } from '@wdio/types'
5+ import type { TransformElement } from 'webdriverio'
56import {
67 BaseClass ,
78 checkElement ,
@@ -142,7 +143,14 @@ export default class WdioImageComparisonService extends BaseClass {
142143 const browserNames = Object . keys ( capabilities )
143144
144145 /**
145- * Add all the commands to each browser in the Multi Remote
146+ * Add all commands to the global browser object that will execute on each browser in the Multi Remote.
147+ */
148+ for ( const [ commandName , command ] of Object . entries ( pageCommands ) ) {
149+ this . #addMultiremoteCommand( browser , browserNames , commandName , command )
150+ }
151+
152+ /**
153+ * Add all commands to each instance (but Single Remote version)
146154 */
147155 for ( const browserName of browserNames ) {
148156 log . info ( `Adding commands to Multi Browser: ${ browserName } ` )
@@ -155,15 +163,6 @@ export default class WdioImageComparisonService extends BaseClass {
155163 await this . #addCommandsToBrowser( browserInstance )
156164 }
157165
158- /**
159- * Add all the commands to the global browser object that will execute
160- * on each browser in the Multi Remote
161- * Start with the page commands
162- */
163- for ( const [ commandName , command ] of Object . entries ( pageCommands ) ) {
164- this . #addMultiremoteCommand( browser , browserNames , commandName , command )
165- }
166-
167166 /**
168167 * Add all the element commands to the global browser object that will execute
169168 * on each browser in the Multi Remote
@@ -234,7 +233,7 @@ export default class WdioImageComparisonService extends BaseClass {
234233 methods : {
235234 bidiScreenshot : isBiDiScreenshotSupported ( browser ) ? this . browsingContextCaptureScreenshot . bind ( browser ) : undefined ,
236235 executor : < ReturnValue , InnerArguments extends unknown [ ] > (
237- fn : string | ( ( ...args : InnerArguments ) => ReturnValue ) ,
236+ fn : string | ( ( ...innerArgs : TransformElement < InnerArguments > ) => ReturnValue ) ,
238237 ...args : InnerArguments
239238 ) : Promise < ReturnValue > => {
240239 return this . execute ( fn , ...args ) as Promise < ReturnValue >
@@ -311,7 +310,7 @@ export default class WdioImageComparisonService extends BaseClass {
311310 methods : {
312311 bidiScreenshot : isBiDiScreenshotSupported ( browser ) ? this . browsingContextCaptureScreenshot . bind ( browser ) : undefined ,
313312 executor : < ReturnValue , InnerArguments extends unknown [ ] > (
314- fn : string | ( ( ...args : InnerArguments ) => ReturnValue ) ,
313+ fn : string | ( ( ...innerArgs : TransformElement < InnerArguments > ) => ReturnValue ) ,
315314 ...args : InnerArguments
316315 ) : Promise < ReturnValue > => {
317316 return this . execute ( fn , ...args ) as Promise < ReturnValue >
@@ -387,7 +386,7 @@ export default class WdioImageComparisonService extends BaseClass {
387386 methods : {
388387 bidiScreenshot : isBiDiScreenshotSupported ( browserInstance ) ? browserInstance . browsingContextCaptureScreenshot . bind ( browserInstance ) : undefined ,
389388 executor : < ReturnValue , InnerArguments extends unknown [ ] > (
390- fn : string | ( ( ...args : InnerArguments ) => ReturnValue ) ,
389+ fn : string | ( ( ...innerArgs : TransformElement < InnerArguments > ) => ReturnValue ) ,
391390 ...args : InnerArguments
392391 ) : Promise < ReturnValue > => {
393392 return browserInstance . execute ( fn , ...args ) as Promise < ReturnValue >
@@ -480,7 +479,7 @@ export default class WdioImageComparisonService extends BaseClass {
480479 methods : {
481480 bidiScreenshot : isBiDiScreenshotSupported ( browserInstance ) ? browserInstance . browsingContextCaptureScreenshot . bind ( browserInstance ) : undefined ,
482481 executor : < ReturnValue , InnerArguments extends unknown [ ] > (
483- fn : string | ( ( ...args : InnerArguments ) => ReturnValue ) ,
482+ fn : string | ( ( ...innerArgs : TransformElement < InnerArguments > ) => ReturnValue ) ,
484483 ...args : InnerArguments
485484 ) : Promise < ReturnValue > => {
486485 return browserInstance . execute ( fn , ...args ) as Promise < ReturnValue >
0 commit comments