简体   繁体   中英

How to tap on google map marker in swift UITest

I want to tap on google marker in google map in ios.

I have one google map and marker on map i want to tap on it. Marker is having icon and one lable with number.

在此处输入图片说明

Something like above.I am also submitting code of adding marker on map.

let pinView = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
let circleArrow = UIImageView(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
circleArrow.image = UIImage(named: "circleArrow")
pinView.addSubview(circleArrow)
let ridersLabel = UILabel(frame: CGRect(x: 0, y: 15, width: 40, height: 20))
ridersLabel.text = "\(riders)"
ridersLabel.textAlignment = .center
ridersLabel.textColor = UIColor.white
ridersLabel.transform = CGAffineTransform(rotationAngle: CGFloat(.pi * self.getLabelRotation(heading: heading) / 180.0))
pinView.addSubview(ridersLabel)
pickupMarker.icon = self.imageFromView(aView: pinView)
pickupMarker.rotation = heading
pickupMarker.groundAnchor = CGPoint(x: 0.5, y: 0.5)
pickupMarker.infoWindowAnchor = CGPoint(x: 0.5, y: 1.0)
pickupMarker.map = self.vwMapView

Currently i am trying to get marker like below code UITestCode.

if (self.app.staticTexts["\(n)"].exists)
{
  let markerAvailable = self.app.staticTexts["2"]
  markerAvailable.tap()
}

Above code in not working.

Solution to at least show pins in accessibility inspector

let mapView = GMSMapView(frame: .zero)
mapView.accessibilityElementsHidden = false

let marker = GMSMarker(position: ...)
marker.accessibilityElementsHidden = false
marker.userData = someString // I used earlgrey to find it by userData, most probably it's possible to find it with default API somehow too

I can search for these pins, but I don't know how to tap them

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM