How to get text from label?

Hi All,

I am using appium flutter driver with wdio and there is one element in heirachy from which I want to extract text for the price and verify it.

Below is the dev code for the same:

return Semantics(
label: text.stripHtml,
child: Wrap(crossAxisAlignment: WrapCrossAlignment.center, children: widgets,),
key: Key(“catalog_product_card_price”)
);

Below is the script code to get text from it:

for (const catalogItem of menClothingSubCatalogMap[subCatalog]) {
log.info(Navigating to ${catalogItem} ${catalog_product_#${index}});
await driver.execute(‘flutter:scrollIntoView’, find.byValueKey(catalog_product_#${index}), { alignment: 0.1 });
await driver.execute(‘flutter:waitFor’, find.byValueKey(catalog_product_#${index}));
const catalogPrice = find.descendant({
of: find.byValueKey(catalog_product_#${index}),
matching: find.bySemanticsLabel(‘catalog_product_card_price’),
});
console.log(‘****************’);
console.log(catalogPrice);

    const price =  await driver.getElementText(catalogPrice);
    const regex = /^[¢£$kc¥€]{1}\d{1,}(\.\d{1,3})?$/ig;
    const results = regex.test(price);
    expect(results).to.be.true;
    index++;
}

In my case getElementText() is not working using above approach.
Can someone pls tell me what I am missing at my end?
Thanks :slight_smile:
Below is the console log for the value of catalogPrice


Below is the error I am facing using getElementText()

what test framework and language bindings are you using? Java? It looks like something is hosed/not initialized. you could dump the page source or DOM and then people can help you a bit more.

Thanks for the reply. Here is the required information:
I am using appium flutter driver with wdio.
Language used in my framework: TypeScript

1 Like

Oh, sorry, I’m not using flutter driver.
I only know how the uiautomator2 and xcuitest webdriver wrappers get used. We may need to actually find some proper docs on the flutter driver and find some examples. They are a totally different thing to drive.

how to get the value of a label in xcuitest webdriver

1 Like