Skip to content

Commit 76a2527

Browse files
committed
actions adjustments
1 parent c57c456 commit 76a2527

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

test/helpers/actions.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,24 @@ export async function expectTextWithin(
175175
const parent = elementById(ancestorId);
176176
await parent.waitForDisplayed();
177177

178+
if (driver.isIOS) {
179+
const parentLabel = await parent.getAttribute('label');
180+
const parentValue = await parent.getAttribute('value');
181+
const matchesParent =
182+
(typeof parentLabel === 'string' && parentLabel.includes(text)) ||
183+
(typeof parentValue === 'string' && parentValue.includes(text));
184+
185+
if (matchesParent) {
186+
if (!visible) {
187+
await parent.waitForDisplayed({ reverse: true, timeout });
188+
}
189+
return;
190+
}
191+
}
192+
178193
const needle = driver.isAndroid
179194
? `.//*[contains(@text,'${text}')]`
180-
: `.//XCUIElementTypeStaticText[contains(@label,'${text}') or contains(@value,'${text}')]`;
195+
: `.//*[self::XCUIElementTypeStaticText or self::XCUIElementTypeTextView or self::XCUIElementTypeTextField][contains(@label,'${text}') or contains(@value,'${text}')]`;
181196

182197
if (!visible) {
183198
await parent.$(needle).waitForDisplayed({ reverse: true, timeout });
@@ -390,10 +405,16 @@ export async function confirmInputOnKeyboard() {
390405
await driver.hideKeyboard();
391406
} catch {}
392407
} else {
408+
for (let el of ['return', 'done', 'go']) {
393409
try {
394-
await elementByText('return').click();
395-
} catch {
396-
// Swallow the error; keyboard might already be closed
410+
let elem = await elementByText(el);
411+
await elem.waitForDisplayed({ timeout: 2000 });
412+
await elem.click();
413+
return;
414+
} catch {
415+
// Swallow the error; keyboard might already be closed
416+
console.warn(`Not closing keyboard on element: ${el}`);
417+
}
397418
}
398419
}
399420
}

0 commit comments

Comments
 (0)