bluemix / Gradient-Widgets

Flutter widgets wrapped with gradients
Apache License 2.0
348 stars 48 forks source link

How to test GradientButton callback #18

Closed Frezyx closed 3 years ago

Frezyx commented 4 years ago

Hello. I use the GradientButton from your package. And action of it is callback function. I write integration test for my application. How can i test it like a tap() on RaisedButton ? Group 2 (1)

bluemix commented 4 years ago

I was having the same issue as yours by not finding the Widget from its value key. You can solve by finding its type:

final SerializableFinder _authButton = find.byType('GradientButton');

Another way (currently I use) is by means of Page Object Model:

await _driver.runUnsynchronized(() async {
      await _driver.tap(_authButton);
});

However, I don't how if find.byType('GradientButton'); will work if you have multiple buttons with the same type on the same view.

Frezyx commented 4 years ago

Thanks a lot for your response ! This helped in finding the element. But there are several of them on the screen, and Flutter responds with this error if on screen are more than one elements of this type.

image 11

Is there any other way to find it ?

bluemix commented 4 years ago

@Frezyx another solution is to try with text search (I am not sure it will click the button):

final SerializableFinder _authButton = find.text('Login');

Did you try this with a find by value-key?

await _driver.runUnsynchronized(() async {
      await _driver.tap(_authButton);
});
Frezyx commented 4 years ago

Unfortunately I've already tried it. Not working with my button :cry: In any case, thank you for answering and suggesting a solution :blush: :thumbsup: