Skip to content

Commit 7191626

Browse files
committed
MOBILE-4081 behat: Improve debugging ergonomics
1 parent 84668aa commit 7191626

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/testing/services/behat-runtime.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,15 @@ export class TestingBehatRuntimeService {
333333
* @param locator Element locator.
334334
* @returns OK if successful, or ERROR: followed by message
335335
*/
336-
async press(locator: TestingBehatElementLocator): Promise<string> {
336+
async press(locator: TestingBehatElementLocator): Promise<string>;
337+
async press(text: string, nearText?: string): Promise<string>;
338+
async press(locatorOrText: TestingBehatElementLocator | string, nearText?: string): Promise<string> {
339+
const locator = typeof locatorOrText === 'string' ? { text: locatorOrText } : locatorOrText;
340+
341+
if (nearText) {
342+
locator.near = { text: nearText };
343+
}
344+
337345
this.log('Action - Press', locator);
338346

339347
try {

0 commit comments

Comments
 (0)