@@ -416,8 +416,7 @@ export async function tabNavigateToWorkspace(
416416 * @param browser The active WebdriverIO Browser object.
417417 */
418418export async function tabNavigateForward ( browser : WebdriverIO . Browser ) {
419- await browser . keys ( webdriverio . Key . Tab ) ;
420- await browser . pause ( PAUSE_TIME ) ;
419+ await sendKeyAndWait ( browser , webdriverio . Key . Tab ) ;
421420}
422421
423422/**
@@ -426,8 +425,7 @@ export async function tabNavigateForward(browser: WebdriverIO.Browser) {
426425 * @param browser The active WebdriverIO Browser object.
427426 */
428427export async function tabNavigateBackward ( browser : WebdriverIO . Browser ) {
429- await browser . keys ( [ webdriverio . Key . Shift , webdriverio . Key . Tab ] ) ;
430- await browser . pause ( PAUSE_TIME ) ;
428+ await sendKeyAndWait ( browser , [ webdriverio . Key . Shift , webdriverio . Key . Tab ] ) ;
431429}
432430
433431/**
@@ -471,20 +469,20 @@ export async function keyDown(browser: WebdriverIO.Browser, times = 1) {
471469}
472470
473471/**
474- * Sends the specified key for the specified number of times, waiting between
475- * each key press to allow changes to keep up.
472+ * Sends the specified key(s) for the specified number of times,
473+ * waiting between each key press to allow changes to keep up.
476474 *
477475 * @param browser The active WebdriverIO Browser object.
478- * @param key The WebdriverIO representative key value to press.
479- * @param times The number of times to repeat the key press.
476+ * @param keys The WebdriverIO representative key value(s) to press.
477+ * @param times The number of times to repeat the key press (default 1) .
480478 */
481- async function sendKeyAndWait (
479+ export async function sendKeyAndWait (
482480 browser : WebdriverIO . Browser ,
483- key : string ,
484- times : number ,
481+ keys : string | string [ ] ,
482+ times = 1 ,
485483) {
486484 for ( let i = 0 ; i < times ; i ++ ) {
487- await browser . keys ( key ) ;
485+ await browser . keys ( keys ) ;
488486 await browser . pause ( PAUSE_TIME ) ;
489487 }
490488}
0 commit comments