Skip to content

Commit c70287a

Browse files
Merge pull request #85 from withhaibun/feature/get-text-stepper
Created a new stepper to retrieve the text contents on the ui
2 parents 88450d7 + 5f89139 commit c70287a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

modules/web-playwright/src/interactionSteps.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,22 @@ export const interactionSteps = (wp: WebPlaywright): TStepperSteps => ({
538538
return OK;
539539
},
540540
},
541+
saveTextFrom: {
542+
gwta: `save text from {element: ${DOMAIN_PAGE_LOCATOR}} to {where}`,
543+
action: async ({ element, where }: { element: string; where: string }, featureStep) => {
544+
const text = await wp.withPage<string>(async (page: Page) => {
545+
const locator = page.locator(element);
546+
// Try textContent first, fall back to inputValue for input elements
547+
const content = await locator.textContent();
548+
if (content !== null && content.trim() !== '') {
549+
return content.trim();
550+
}
551+
return await locator.inputValue();
552+
});
553+
wp.getWorld().shared.set({ term: where, value: text, domain: 'string', origin: Origin.fallthrough }, provenanceFromFeatureStep(featureStep));
554+
return OK;
555+
},
556+
},
541557
resizeWindow: {
542558
gwta: 'resize window to {width}x{height}',
543559
action: async ({ width, height }: { width: string; height: string }) => {

0 commit comments

Comments
 (0)