In Flutter Application How to test a registration form opened through a server url like localhost.9xxxxx etc I want to do test automation of form filling .

I have a flutter mobile and web application where in which users are allowed to create account for the first time and members who already created account can login using email or username and password.

Please help with test automation for the above.

Note : My link is a hosting server url.

I want to perform flutter test automation for opening the url and form filling like creation of account and Sign in please help me with all the above

Built a basic url_launcher and webview flutter application which opens a normal url like yahoo.com and google.com and performed test using flutter_driver and test dependancies.

  > import 'package:flutter/material.dart';
    > import 'package:url_launcher/url_launcher.dart';
    > 
    > class MainScreen extends StatefulWidget {
    > const MainScreen({super.key});
    > 
    >   @override
    > State<MainScreen> createState() => _MainScreenState();
    > }
    > 
    > ```
    > class _MainScreenState extends State<MainScreen> {
    > 
    > Future<void> _launchURL(String url) async {
    > final Uri uri = Uri(scheme: "https", host: url);
    > if(!await launchUrl(
    > uri,
    > mode: LaunchMode.externalApplication,
    >     )) {
    > throw "Can not launch url";
    >     }
    >   }
    > 
    >   @override
    > Widget build(BuildContext context) {
    > return Scaffold(
    > body: Center(
    > child: Container(
    > height: 50,
    > width: 120,
    > color: Colors.red,
    > child: Center(
    > child: GestureDetector(
    > onTap: () {
    > _launchURL("www.google.com");
    >               },
    > child: const Text("Launch URL"),
    >             ),
    >           ),
    >         ),
    >       ),
    >     );
    >   }
    > }

For Testing

import 'package:flutter_driver/flutter_driver.dart'; import 'package:test/test.dart';

void main() {

group('URL Opening Tests', () { FlutterDriver? driver;

setUpAll(() async { driver = await FlutterDriver.connect(); });

tearDownAll(() async { if (driver != null) { driver?.close(); } });

test('Open URL Using url_launcher', () async { await driver?.tap(find.byType('ElevatedButton'));

});

}); }

1

There are 1 answers

0
thoughtfocus On

At last I have successfully achieved it by using chrome for Testing Browser and same version chrome webdriver but it has limitations like we cannot launch the application on local host directly but after running the application or compiling the application it will be hosted on a local host port and then we have to run that port on chrome for Testing Browser.