Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make maxIteration a parameter for isElementVisible
  • Loading branch information
jostnes committed May 10, 2022
commit 85c407c286fc18e226f98fbcfa440237f995d093
16 changes: 13 additions & 3 deletions packages/react-native-editor/__device-tests__/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,16 @@ const waitForVisible = async ( driver, elementLocator, iteration = 0 ) => {
/**
* @param {string} driver
* @param {string} elementLocator
* @param {number} maxIteration - Default value is 25, can be adjusted to be less to wait for element to not be visible
* @param {number} iteration - Default value is 0
* @return {boolean} - Returns true if element is found, false otherwise
*/
const isElementVisible = async ( driver, elementLocator, iteration = 0 ) => {
const maxIteration = 5;
const isElementVisible = async (
driver,
elementLocator,
maxIteration = 25,
iteration = 0
) => {
const timeout = 1000;

if ( iteration >= maxIteration ) {
Expand All @@ -513,7 +518,12 @@ const isElementVisible = async ( driver, elementLocator, iteration = 0 ) => {
const locator = await driver.elementsByXPath( elementLocator );
if ( locator.length !== 1 ) {
// if locator is not visible, try again
return isElementVisible( driver, elementLocator, iteration + 1 );
return isElementVisible(
driver,
elementLocator,
maxIteration,
iteration + 1
);
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ class EditorPage {
? '//android.widget.HorizontalScrollView[@content-desc="Slash inserter results"]/android.view.ViewGroup'
: '(//XCUIElementTypeOther[@name="Slash inserter results"])[1]';

return await isElementVisible( this.driver, slashInserterLocator );
return await isElementVisible( this.driver, slashInserterLocator, 5 );
}

// =========================
Expand Down