How to Tap on native iOS popup to allow Notifications. (Flutter Integration Test) - flutter

Flutter Driver code has to tap on the native "Allow" button to continue and simulate the correct user behaviour.
See this screenshot. Native iOS popup before app starts - Allow Notifications
App has not yet completely started and is waiting for this tap.
How does one get the driver to tap on the native iOS popup?
Any suggestions and ideas are welcome.
Here is the code for one attempt to wait for the app before continuing with other tests; it just awaits indefinitely:
setUpAll(() async {
driver = await FlutterDriver.connect();
await driver.waitUntilFirstFrameRasterized();
});
Here is another attempt at finding the word "Allow" in the popup and tapping on it:
test('Allow app to send Notifications.', () async {
final allow = find.byTooltip("Allow");
await delay(750);
await driver.tap(allow);
});
It does not find the word.
The issue is probably that Flutter Driver is not aware of the iOS native popup.
Other tests are very simple once in the app, for example, to tap on fields, enter text, scroll pages, etc.
Any ideas on how to do this?

Unfortunately this feature is currently not possible. Flutter Driver can't interact with native elements (v1.20.4).
https://github.com/flutter/flutter/issues/34345
https://github.com/flutter/flutter/issues/12561

Related

Not receiving firebase dynamic link

Currently I am doing a project that calls a secondary app and I launch the 2nd app through InAppWebView. While the 2nd app is facing the user, the inappwebview is still running and sends live update, which I am capturing to trigger events, for example like it will send payment complete, allowing me to trigger to go summary page.
The issue I am having is, I am unable to smoothly transit back to my app. So there are two ways that I found that allow me to go back to the app.
One, launch the URL using my dynamic link but this method I am unable to receive the link.
Second, to launch it through external application like chrome.
The second method works perfectly other than the fact that the screen jumps to chrome. And it continues from where I left off.
However, what I want is both, continue from where I left off and not have the jumping of the chrome. Or from what I have read the right way is to direct to the activity using intent filter. But the smooth method I am not receiving the links but the jump method I am receiving the links.
Please help T - T
if you need to add dynamic links with firebase you can find the setup right in the docs and with the help with firebase_dynamic_links you can handle where to go inside your app and also can execute parameters from the link in the function below you make a stream that listen to any dynamic link clicked while the app in the background or foreground , the PendingDynamicLinkData is when the app terminated. the business logic and how the app interacts ups to you.
static Future<void> initDynamicLink() async {
FirebaseDynamicLinks.instance.onLink.listen((dynamicLink) async {
if (dynamicLink.link != Uri.parse("uri")) {
log(dynamicLink.link.queryParameters.toString());
final Uri deepLink = dynamicLink.link;
// you should handle the navigation or you logic here
}
}).onError((error) {
debugPrint("error from dynamic link Stream : : :: ${error.toString()}");
});
final PendingDynamicLinkData? initialLink =
await FirebaseDynamicLinks.instance.getInitialLink();
try {
if (initialLink != null) {
log(initialLink.link.toString());
final Uri deepLink = dynamicLink.link;
// you should handle the navigation or you logic here
}
} catch (e) {
debugPrint('No deepLink found');
}
}
don't forget to call this function in the main like this
void main()async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
initDynamicLink();
}

Using uni_links when the app is in the background

My application has the following structure:
- InheritedWidget for dependencies
--> Splash Screen Page
--> Login Pages
--> Main Pages
When the app runs for the first time, I can use var link = await getInitialLink(); to get the value for the link that opened the app.
However, I cannot get the same result if I open the app on the background.
I tried to use
getLinksStream().listen((link) => (link) {
try {
var _latestUri;
if (link != null) _latestUri = Uri.parse(link);
print("=== Formated successfully a link!");
} on FormatException {
print("--- A link got here but was invalid");
}
});
For getting the link in the Splash Screen, but if the app is already open in the Login or Main pages, it won't go through the Splash Screen again.
Then, I tried to put it in the InheritedWidget, but alas, didn't get any result whatsoever.
So my question is: Where and how should I set up uni_links so that I can catch all incoming links even if the app is open?
Or better, is there an alternative for App Links/Universal Links that I can use?
Though it's not the best and most elegant way, I got around this.
First, I was not using getLinksStream correctly
Instead of
(link) => (link) {...}
It's
(link) {...}
Then, I need to put this subscription in my Splash Screen and do not dispose of it, so that it can listen to new events.
If anybody has a better solution, please free to add it
For this situation, you need to use both of getInitialUri() and getUriLinksStream(),
If app launchs directly u will get uri from getInitialUri, if app already running on background u will get uri from getUriLinksStream.

How can create Google TTS button flutter?

I found this code but I need help turning it to button
when I clicked button speech hello world.
https://pub.dartlang.org/packages/flutter_tts#-example-tab-
This plugin requires Android SDK 21+, so you need to change project settings first. To do that open android/app/build.gradle, and change minSdkVersion to 21.
After that everything should work just the way it's described in the documentation and your button's click handler function may look like this:
FlutterTts flutterTts = new FlutterTts();
await flutterTts.speak("Hello World");

In Flutter widget testing, how to pause app to find suggested Finder?

I am following flutter widget testing as https://flutter.io/testing/#widget-testing.
It says that
simply flutter run test/widget_test.dart to see your test run in your preferred runtime environment such as a simulator or a device. During a flutter run session on a widget test, you can also interactively tap parts of the screen for the Flutter tool to print the suggested Finder.
I am using flutter run test/widget_test.dart so that i can tap and get suggested finders. But I am not able to pause the test so that i can actually tap. The test runs and automatically ends. So that there are no widgets on the screen except Text('Test Finished').
Thank you very much!
I know it's been almost 2 years since the question was asked, but anyway. tester.idle() helped me to pause an app.
testWidgets('idle', (WidgetTester tester) async {
await tester.pumpWidget(
//
);
await tester.tap(find.byIcon(Icons.bluetooth));
await tester.pump();
tester.idle();
});

Detox test stalls when moving between text inputs iPad

I have followed the instructions at https://github.com/wix/detox, created a few simple tests and run them successfully on an iPhone sim. However, when using an iPad (ios 11.2) it stalls after entering text in the first of two text inputs (for a login screen). My test is as follows
it('should log in and take user to feed', async () => {
await element(by.id('email')).typeText('email')
await element(by.id('password')).typeText('password')
await element(by.id('loginButton')).tap()
await expect(element(by.id('feed'))).toBeVisible()
})
As I say, all tests pass on iPhone but not iPad, and when viewing the sim it clearly hangs between the first and second text field. I've also tried replaceText() which results in a failed test, I think due to this issue with EarlGrey https://github.com/wix/detox/issues/151.
I searched around the problem and I think it's related to this https://github.com/google/EarlGrey/issues/239#issuecomment-247737738. If anyone knows a fix I'd be very grateful.
Thanks.