如何在应用程序上实现iOS 3D触摸自动化?

问题描述 投票:0回答:1

[我为我的iOS应用编写了Appium UI测试。一些测试具有这样的工作流程:

  1. 一个应用被发送到后台
  2. 用户在应用程序的图标上进行“强制触摸”,直到出现菜单(快捷方式)
  3. 通过此快捷方式启动应用程序

我的环境:

  • 模拟器iOS 13.2
  • appium 1.15.0
  • Appium Python客户端0.47

我已经尝试过此类代码(Python),它不会“强制触摸”:

self.driver.background_app(-1) # this works: sends an app to backround
args = {'duration': 5, 'x': 200, 'y': 200}
self.driver.execute_script("mobile:touchAndHold", args) # this doesn't work: force touch on Home screen

((我尝试调整坐标,例如(150,200),(260,400)-未按下任何应用程序图标)。

我已经尝试过AppleScript,但是现在我所能做的就是激活Simulator应用。 :)

我发现的东西但是不起作用:

[https://saucelabs.com/blog/how-to-automate-3d-force-touch-with-appium:在本文中,“ press”命令与“ element” = AppName一起使用,但是我的硒驱动程序说“ press”需要“ x”,“ y”,而不是“ element”]

[https://developers.perfectomobile.com/display/TT/Using+iOS+3D+Touch:在本文中,使用了driver.executeScript("mobile:touch:tap", parms),但我的驱动程序说没有命令“ mobile:touch:tap”:

selenium.common.exceptions.WebDriverException: Message: Unknown mobile command 'touch:tap'. Only scroll, swipe, pinch, doubleTap, twoFingerTap, touchAndHold, tap, dragFromToForDuration, selectPickerWheelValue, alert, setPasteboard, getPasteboard, source, getContexts, installApp, isAppInstalled, removeApp, launchApp, terminateApp, queryAppState, activateApp, viewportScreenshot, startPerfRecord, stopPerfRecord, installCertificate, startLogsBroadcast, stopLogsBroadcast, batteryInfo, deviceInfo, activeAppInfo, pressButton, enrollBiometric, sendBiometricMatch, isBiometricEnrolled, clearKeychains, getPermission, siriCommand commands are supported.

我看过XCUITestDriver文档/代码,例如https://github.com/appium/appium-xcuitest-driver/blob/master/lib/commands/execute.js,并且看不到任何3D-touch相关内容。

所以您知道:1.如何在iOS Simulator中自动对应用程序图标进行3D触摸?2.如何检查XCUITest-Driver是否支持它?3.它可以像AppleScript一样通过自动化实现吗?

提前感谢:)

ios automated-tests appium 3dtouch xcuitest
1个回答
0
投票

如果您的意思像是https://i.stack.imgur.com/3Fo7v.png,则可以如下所示打开它。(Ruby代码)

# Long press 'Contacts' icon with W3C actions
el = @driver.find_element :name, 'Contacts'
action_builder = @driver.action
action_builder.move_to(el)
              .pointer_down(:left)
              .pause(action_builder.pointer_inputs[0], 2)
              .pointer_up(:left).perform

https://appium.io/docs/en/commands/interactions/actions/是API。您也可以找到Python。

((iOS 13不提供'3D触摸'。此功能是长按样式)

© www.soinside.com 2019 - 2024. All rights reserved.