From 7191626f2c04e15e640264ff54423d5ef638605e Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Thu, 15 Dec 2022 13:04:49 +0100 Subject: [PATCH] MOBILE-4081 behat: Improve debugging ergonomics --- src/testing/services/behat-runtime.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/testing/services/behat-runtime.ts b/src/testing/services/behat-runtime.ts index e514da1ce..892667cca 100644 --- a/src/testing/services/behat-runtime.ts +++ b/src/testing/services/behat-runtime.ts @@ -333,7 +333,15 @@ export class TestingBehatRuntimeService { * @param locator Element locator. * @returns OK if successful, or ERROR: followed by message */ - async press(locator: TestingBehatElementLocator): Promise { + async press(locator: TestingBehatElementLocator): Promise; + async press(text: string, nearText?: string): Promise; + async press(locatorOrText: TestingBehatElementLocator | string, nearText?: string): Promise { + const locator = typeof locatorOrText === 'string' ? { text: locatorOrText } : locatorOrText; + + if (nearText) { + locator.near = { text: nearText }; + } + this.log('Action - Press', locator); try {