From 35293d943ca44f365ad9df5ea7c43e708062df1b Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 10 Oct 2023 12:26:37 -0400 Subject: [PATCH] test: Update Search tests for Appium 2 (#55170) * test: Update getSearchBlockTextElement query Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade. * test: Update waitForElementToBeDisplayedByXPath query Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade. * test: Update verifySearchElementText query Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade. * test: Update getSearchBlockTextElement query Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade. --- .../gutenberg-editor-search.test.js | 2 +- .../__device-tests__/pages/editor-page.js | 23 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/react-native-editor/__device-tests__/gutenberg-editor-search.test.js b/packages/react-native-editor/__device-tests__/gutenberg-editor-search.test.js index 95082777711b3..6aea27dab063a 100644 --- a/packages/react-native-editor/__device-tests__/gutenberg-editor-search.test.js +++ b/packages/react-native-editor/__device-tests__/gutenberg-editor-search.test.js @@ -151,7 +151,7 @@ const verifySearchElementText = async ( testId, expected ) => { if ( isAndroid() ) { const input = await editorPage.getSearchBlockTextElement( testId ); - const inputValue = await input.text(); + const inputValue = await input.getText(); actual = inputValue.trim(); } else { actual = await editorPage.getHtmlContent(); diff --git a/packages/react-native-editor/__device-tests__/pages/editor-page.js b/packages/react-native-editor/__device-tests__/pages/editor-page.js index d102a7620a672..b4a433d5c1ab9 100644 --- a/packages/react-native-editor/__device-tests__/pages/editor-page.js +++ b/packages/react-native-editor/__device-tests__/pages/editor-page.js @@ -1,9 +1,3 @@ -/** - * External dependencies - */ -// eslint-disable-next-line import/no-extraneous-dependencies -const wd = null; // TODO: Replace this - /** * Internal dependencies */ @@ -843,12 +837,12 @@ class EditorPage { // ============================= async getSearchBlockTextElement( testID ) { - const child = await this.driver.elementByAccessibilityId( testID ); + const child = await this.driver.$( `~${ testID }` ); if ( isAndroid() ) { // Get the child EditText element of the ViewGroup returned by // elementByAccessibilityId. - return await child.elementByClassName( 'android.widget.EditText' ); + return await child.$( 'android.widget.EditText' ); } return child; @@ -989,11 +983,14 @@ class EditorPage { } async waitForElementToBeDisplayedByXPath( id, timeout = 2000 ) { - return await this.driver.waitForElementByXPath( - id, - wd.asserters.isDisplayed, - timeout - ); + const element = await this.driver.$( `${ id }` ); + + if ( element ) { + return element; + } + + await element.waitForDisplayed( { timeout } ); + return element; } }