【问题标题】:How to tap on google map marker in swift UITest如何在swift UITest中点击谷歌地图标记
【发布时间】:2020-06-18 00:38:45
【问题描述】:

我想在 ios 的谷歌地图中点击谷歌标记。

我有一张谷歌地图和地图上的标记,我想点击它。标记有图标和一个带数字的标签。

类似上面的东西。我也在提交在地图上添加标记的代码。

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

目前我正在尝试获取如下代码 UITestCode 的标记。

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

上面的代码不起作用。

【问题讨论】:

  • 你找到解决办法了吗?
  • @PaulT。还没有,但我发现了其他自定义方法可以通过一些应用程序级别的更改来做到这一点。
  • 我找到了一个解决方案,不是很理想,但至少有效,请看下面我的回答

标签: ios swift google-maps google-maps-markers uitest


【解决方案1】:

至少在可访问性检查器中显示引脚的解决方案

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

我可以搜索这些图钉,但我不知道如何点击它们

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多