Test: How can I tap on a Google Map marker inside my app using maestro mobile UI testing framework

62 views Asked by At

I'm new to programming and Maestro. I'm developing a native application using Vue3 and Nativescript that uses the Google Maps plugin. I've added multiple markers on the map and need to perform some tests, specifically tapping on a marker. I have installed Maestro with Maestro Studio. I've tried to write some tests in .yaml, but it doesn't work. I cannot tap on the marker on the map. Here is the code from my app where I add a marker:

<script lang="ts" setup>
import { ref, $navigateBack } from 'nativescript-vue';
import { GoogleMap, MapType, MapReadyEvent, MapView, MarkerOptions, Marker, MapTapEvent } from '@nativescript/google-maps';

const mapView = ref<GoogleMap | null>(null);
function onReady(event: MapReadyEvent) {
  mapView.value = event.map;

  const markerOptions: MarkerOptions = {
    position: {
        lat:51.33,
        lng:12.37
    },
    title: "New_Marker",

};
  const newMarker: Marker = event.map.addMarker(markerOptions);
  console.log("MARKEER INFO: " + newMarker);

}
function onTap(event: MapTapEvent) {
  console.log("Map tapped!", event);

}
function addMarker(map: GoogleMap, markerOptions: MarkerOptions): Marker {
  return map.addMarker(markerOptions);
}

function mapLongPress(event: MapTapEvent){



}

</script>

<template>
<Page actionBarHidden="true">
<GridLayout rows="auto, *">
<Label
      testID="goBack"
        text="Go Back"
        @tap="$navigateBack"
        class="text-center px-4 py-10 text-2xl text-gray-900 font-bold"
      />


<ContentView row="1" class="bg-[#65adf1] rounded-t-3xl">
<MapView
        testID="gMaps"
        @onTap ="onTap"        
        @ready="onReady"
        @mapLongPress="mapLongPress"


/>
</ContentView>
</GridLayout>
</Page>
</template>

and here is my firstTest.yaml:

appId: org.nativescript.myAwesomeApp


- launchApp:
      clearState: true


- tapOn:
      id: "gMap"
- tapOn:
        containsDescendants:
        text: "New_Marker"`

here is output in terminal:

Waiting for flows to complete...

[Failed] markerTest (41s) (Element not found: Text matching regex: New_Marker)

1/1 Flow Failed

0

There are 0 answers