4

We are trying to create automated tests for Mapbox's Maps SDK for Android based native mobile application. The automated tests need to determine the number of markers present on the screen, the number of marker clusters present on the screen, click on marker or cluster etc.

When looking at the Mapbox maps on Android application through UIAutomatorViewer or through Appium inspector, the markers visible on the map are not shown in the object hierarchy.

What can the Android native mobile application development team do to surface the markers/clusters so that they are visible to Appium?

Alternately, what other options can the automation team explore to develop automated tests? Espresso is not ideal as automation team does not have access to source code for the native mobile application.

Please see Mapbox demo application's -> Annotations -> Draw a marker for an example of a marker that we would like to detect and click on.

Wasiq Bhamla
  • 949
  • 1
  • 7
  • 12
Dhwanil Shah
  • 1,072
  • 1
  • 9
  • 25
  • You can ask your dev team to add same resource-id for all marker but with different automationId (cont-desc) for each marker. The you will be able to count the number of marker present in the screen using id (**List = driver.findElementsById("...")**) and click separate marker using automation id(**MobileElement = driver.findElementByAccessibilityId("...")**). – Suban Dhyako Dec 21 '18 at 06:27
  • Mapbox's [MarkerOptions](https://www.mapbox.com/android-docs/api/map-sdk/5.0.1/com/mapbox/mapboxsdk/annotations/MarkerOptions.html) or [MarkerViewOptions](https://www.mapbox.com/android-docs/api/map-sdk/5.0.1/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.html) do not seem to allow for setting resource-id or automationId. Can you please share a Mapbox specific example where this is implemented? – Dhwanil Shah Dec 21 '18 at 13:21
  • Can't MarkerOptions be put inside view? If it can be placed inside view, you can add id there. – Suban Dhyako Dec 29 '18 at 02:31

2 Answers2

3

Since the Mapbox SDK uses OpenGL rendering, not native components, most test automation frameworks won't be able to recognise UI elements like the markers or clusters you add to the map.

There are some testers using image recognition from the Accelerated-KAZE Features project to find items on screen in order to count and select them. Some example code can be found at https://github.com/bitbar/bitbar-samples/tree/master/image-recognition

Another approach may be to have the mobile app developers include testing hooks that allow your testing code to use the Mapbox API to query rendered features. Mapbox documentation for that is here: https://www.mapbox.com/android-docs/maps/overview/query/#query-rendered-features

Simon Biber
  • 497
  • 4
  • 5
0

I had come across this scenario earlier that an element, even when it's displayed on the screen, was not highlighted when selected from Appium inspector.

Later, when I scanned the complete hierarchy tree clicking on each node was I able to find the element.

I would suggest you to click on every node and check, the marker will be there in the hierarchy tree. It's just that inspector cursor is not able to highlight it.

Wasiq Bhamla
  • 949
  • 1
  • 7
  • 12