Issue #374

Interact with GMSMapView

Add accessibilityIdentifier to the parent view of GMSMapView. Setting directly onto GMSMapView has no effect

accessibilityIdentifier = "MapView"
let map = app.otherElements.matching(identifier: "MapView").element(boundBy: 0)
map.pinch(withScale: 2, velocity: 1)
map.rotate(CGFloat.pi/3, withVelocity: 1.0)

Interact with GMSMarker (1st try)

Need to enable accessibility

mapView.accessibilityElementsHidden = false

Can’t use pinch to zoom out with UITests, so need to mock location !!!

map().pinch(withScale: 0.05, velocity: -1)

Need to use gpx to mock to preferred location

let map = app.otherElements[Constant.AccessibilityId.mapView.rawValue]
let pin = app.otherElements
            .element(boundBy: 0)

Try isAccessibilityElement = true for PinView, can’t touch!! Use coordinate, can’t touch !!

let coordinate = pin.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5))

Try traversing all the pins, can’t touch

Array(0..<pins.count).forEach {
    let pin = pins.element(boundBy: $0)
    if pin.isHittable {

When po app.otherElements, coordinates are outside screen

Other, {{1624.0, 1624.0}, {30.0, 30.0}}, identifier: 'pin', label: 'Hello world'

Interact with GMSMarker (works)

My PinView has isHittable being false, no matter how I use coordinate or enable it. It can’t be touched.

Go to Xcode -> Open Developer Tool -> Accessibility Inspector to inspect our app in iOS simulator


It turns out that if I do

po app.buttons

It shows all the GMSMarker, but with identifier having class name MyApp.MyStopMarker, so just need to use buttons

extension NSPredicate {
    static func contains(identifier: String) -> NSPredicate {
        return NSPredicate(format: "identifier CONTAINS[c] '\(text)'")

let pin = map()
    .element(boundBy: 0)