Is that possible to tap by coordinates? #1925
Replies: 3 comments 1 reply
-
I believe you should be able to use keys as explained in the intro guide: https://patrol.leancode.co/getting-started. I would advise not to use tapping by coordinates unless absolutely necessary. If you change the layout all your tests get nuked. For tapping at coordinates you can still use the regular flutter integration testing API. Note that in patrol you can access tester this way: Generated via GPT (vanila Flutter, no patrol): import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('Tap by coordinates', (WidgetTester tester) async {
// Initialize the app or the specific screen you want to test
// await tester.pumpWidget(MyApp());
// Define the coordinates
final Offset tapPosition = Offset(100, 200); // Change these values to your desired coordinates
// Execute the tap
await tester.tapAt(tapPosition);
// Add further assertions or checks if needed
// await tester.pumpAndSettle();
// Example assertion
// expect(find.text('Expected Result'), findsOneWidget);
});
} Here's an example of such an util (real example): // Right clicks on an element.
// Useful in scenarios where we need to activate an options menu.
// Can execute code before releasing the right mouse button if we need to query anything.
rightClick(
PatrolIntegrationTester $,
PatrolFinder finder, [
Function()? beforeButtonUp,
]) async {
final TestGesture gesture = await $.tester.startGesture($.tester.getCenter(finder), buttons: kSecondaryMouseButton);
await $.tester.pump();
if (beforeButtonUp != null) {
beforeButtonUp();
}
await gesture.up();
await $.tester.pump();
} Ans usage: patrolTest(
'HF, SpacesAndShortcutsEventReminder - Renders all the ui elements',
($) async {
await $.pumpWidgetAndSettle(VisualSpaceApp());
await $(#developmentPanel).$(#goToPosts).tap();
final spaceBtn = $(#spacesAndShortcutsSlimbar).$(Symbol('space-brains'));
await rightClick($, spaceBtn); |
Beta Was this translation helpful? Give feedback.
-
Do you have any news about this ? |
Beta Was this translation helpful? Give feedback.
-
Just found this in the code:
|
Beta Was this translation helpful? Give feedback.
-
on IPhone there are no classNames or resourceIds, so it's not clear how to tap on the specific element, if it doesn't contain any text.
Beta Was this translation helpful? Give feedback.
All reactions