So, I have problems with testing my Google Map functionality. In my activty I have callback onMapClick(LatLng latlng)
in which there is method to show/hide toolbar. Now, I would like to test it, but I have no clue how to perform click on the map. I tried to use this:
onView(withContentDescription("Mapa Google")).perform(click());
and this:
UiDevice device = UiDevice.getInstance(getInstrumentation());
UiObject map = device.findObject(new UiSelector()
.descriptionContains("Mapa Google"));
map.click();
but it seams that, it doesn't work. Do you know how can I test this kind of behavior?
Assuming Google is never wrong Stories of people driving into lakes or streams of molten lava make for good newspaper headlines, but they do demonstrate that while Google Maps is incredibly accurate it can still contain mistakes.
The best way is UiAutomator library , https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html
private UiDevice uiDevice = UiDevice.getInstance(getInstrumentation());
private UiObject mMarker1 = uiDevice.findObject(new UiSelector().descriptionContains("The title of marker"));
try {
mMarker1.click();
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}
for taping on map you can use this
uiDevice.click(x, y);
x and y are the coordinates
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With