Skip to content

Commit

Permalink
fix: click paste button
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanmo226 committed Oct 23, 2024
1 parent ba94313 commit 64504f7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions appium/tests/helpers/ElementHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,24 @@ class ElementHelper {
static async waitAndPasteString(element: WebdriverIO.Element, text: string) {
await ElementHelper.copyStringIntoClipboard(text);
await browser.pause(100);
await ElementHelper.waitAndClick(element);
await this.clickPasteButtonWithRetries(element);
}

static async clickPasteButtonWithRetries(element: WebdriverIO.Element, maxRetries = 10) {
const pasteEl = await $('~Paste');
await ElementHelper.waitAndClick(pasteEl);

for (let attempt = 1; attempt <= maxRetries; attempt++) {
await ElementHelper.waitAndClick(element);

if (await pasteEl.isDisplayed()) {
await ElementHelper.waitAndClick(pasteEl);
return; // Successfully clicked the paste button
}

await browser.pause(300); // Pause before retrying
}

throw new Error(`Failed to click the Paste button after ${maxRetries} attempts`);
}

static waitClickAndType = async (element: WebdriverIO.Element, text: string) => {
Expand Down

0 comments on commit 64504f7

Please sign in to comment.