简体   繁体   English

如何在 swift UITest 中点击谷歌地图标记

[英]How to tap on google map marker in swift UITest

I want to tap on google marker in google map in ios.我想在 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.目前我正在尝试获得如下代码 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我可以搜索这些图钉,但我不知道如何点按它们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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