0

The element I need to find is situated (in the child element):

 static Widget _buildProjectCategoryWidget(BuildContext context, String name) {
final themeData = Theme.of(context);
final primaryTextTheme = themeData.primaryTextTheme;
return Container(
  padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 5.0),
  decoration: BoxDecoration(borderRadius: BorderRadius.circular(13.0), color: FlAppStyles.altButtonColor),
  child: Text(name, style: primaryTextTheme.textSmall),
);

I tried to find the child element with this, but I have DriverError: Failed to fulfill Tap due to remote error:

SerializableFinder message = find.text("mytext");
    await driver.waitFor(message);
    expect(await driver.getText(message), "mytext"); await driver.tap(buttonChangeProfession);
    

Im a beginner to flutter integration testing, dont know what is wrong, please help. I also tried adding a key and find element by it, but the point is I need to find the text of that element.

1
  • It would help to know what the full error message is and how the finder buttonChangeProfession is defined.
    – SoftWyer
    Commented Dec 18, 2020 at 14:46

2 Answers 2

3

Try this, if you want to verify that this text exists on screen:

expect(
      await driver.getText(find.text("enter text you want to find")),
      "enter text you want to find");

Try this, if you want to tap on that text:

  final elementFinder= find.text('enter text you want to tap');
  await driver.waitFor(elementFinder);
  await driver.tap(elementFinder);

Please get that text by inspecting using Devtool if you are not sure about it, hope this helps

0

See: https://github.com/ashwithpoojary98/javaflutterfinder/issues/8 Issue in ashwithpoojary98

Text and Visibility check:
The getText() and isDisplayed() methods are not implemented in the Element class of Flutter Driver. Instead, you can use the getTextFinder() and waitFor() methods to retrieve the text of an element and check if it is visible.
final element = find.byValueKey('my_element_key');
final textFinder = find.descendant(of: element, matching: find.text('my_text'));

await driver.waitFor(element);
final text = await driver.getText(textFinder);
print(text);

await driver.waitFor(element);
final isVisible = await driver.waitFor(element).isPresent;
print(isVisible);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.