0

The screenshot image that i received, does not include the status bar portion of the app. As you can see below(the first image), the very upper part of the app is being cut off.

1st Image

The 2nd image is the kind of image i am expecting but failed to obtained.

2nd Image

// My screenshot_test.dart

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:end_point/main.dart' as app;

void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();

  group('App test', () {
    testWidgets("test infinite pagination", (tester) async {
        
      app.main();
      await tester.pumpAndSettle();
      await binding.convertFlutterSurfaceToImage();
      await tester.pumpAndSettle();
      await binding.takeScreenshot('screenshot-home');
      await tester.pumpAndSettle();
    });
  });
}

// my integration_test.dart

import 'dart:io';
import 'package:integration_test/integration_test_driver_extended.dart';

Future<void> main() async {
  await integrationDriver(
    onScreenshot: (String screenshotName, List<int> screenshotBytes) async {
      final File image = File('ss/$screenshotName.png');
      image.writeAsBytesSync(screenshotBytes);
      // Return false if the screenshot is invalid.
      return true;
    },
  );
}

I run the code using

"flutter drive
--driver=test_driver/integration_test.dart
--target=integration_test/screenshot_test.dart
-d iPhone SE"

1 Answers1

0

Try to adjust screen resolution:

flutter drive \
  --driver=test_driver/integration_test.dart \
  --target=integration_test/screenshot_test.dart \
  --size=750x1334 \
  -d iPhone SE
angwrk
  • 394
  • 1
  • 8
  • I am getting this "Could not find an option named "size"." error, tried searching online but was unable to find similar problem. In additional i have tried setting the window size with these code: `final width = 750;` `final height = 1334;` `final dpi = tester.binding.window.devicePixelRatio;` `tester.binding.window.physicalSizeTestValue = Size(width * dpi, height * dpi);` But it doesn't really do anything too. – Lim Jiexian Mar 14 '23 at 09:53
  • I found this website https://keyholesoftware.com/2023/02/13/automating-flutter-deployments-part-2-screenshots/#respond post, the person was facing the same problem and she mentioned that the reason why this is happening because "integration_test package takes screenshots within the context of the Flutter application; it doesn’t know about OS features like status bars". I am trying out her solution and if i managed to get it working, i will post it here. – Lim Jiexian Mar 14 '23 at 09:59