【问题标题】:Unable to run Appium tests on iOS using autoAcceptAlerts无法使用 autoAcceptAlerts 在 iOS 上运行 Appium 测试
【发布时间】:2015-05-27 02:54:16
【问题描述】:

我在 Mac OS X 上使用 Appium 1.3.6,并用 C# 编写测试。 我在我的测试初始化​​中添加了 autoAcceptAlerts 能力参数,所以它看起来像这样:

Console.WriteLine("Connecting to Appium server...");
capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.BrowserName, "iOS");
capabilities.SetCapability(CapabilityType.Platform, "Mac 10.10");
capabilities.SetCapability(CapabilityType.Version, version);
capabilities.SetCapability("deviceName", device);
capabilities.SetCapability("autoAcceptAlerts", true);

driver = new IOSDriver(new Uri("my-appium-URL"), capabilities);

Console.WriteLine("Connection established.");

而且添加后,我只能偶尔成功启动测试。大多数时候我看到应用程序启动,警报关闭,主要活动显示,但随后测试失败。我在日志中看到的是:

Given I start app for iOS 8.1 on iPad Retina
Connecting to Appium server...
-> error: The HTTP request to the remote WebDriver server for URL <my-appium-URL> timed out after 60 seconds.

并且来自 Appium 日志:

info: [debug] [INST] 2015-03-23 22:29:39 +0000 Debug: target.frontMostApp().alert().buttons()[1].tap()
info: [debug] [INST] 2015-03-23 22:29:40 +0000 Debug: Waiting for alert to close...
info: [debug] [INST] 2015-03-23 22:29:40 +0000 Debug: Waiting for alert to close...
info: [debug] [INST] 2015-03-23 22:29:41 +0000 Debug: Got new command 1 from instruments: au.setScreenOrientation('PORTRAIT')
info: [debug] [INST] 2015-03-23 22:29:41 +0000 Debug: evaluating au.setScreenOrientation('PORTRAIT')
info: [debug] [INST] 2015-03-23 22:29:41 +0000 Debug: target.setDeviceOrientation("1")
info: [debug] [INST] 2015-03-23 22:29:42 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-03-23 22:29:42 +0000 Debug: responding with:
info: [debug] [INST] 2015-03-23 22:29:42 +0000 Debug: Running system command #2: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":"PORTRAIT"}...
info: [debug] Socket data received (33 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":"PORTRAIT"}
info: [debug] Waiting for app source to contain elements
info: [debug] Pushing command to appium work queue: "au.mainApp().getTreeForXML()"
info: [debug] Sending command to instruments: au.mainApp().getTreeForXML()
info: [debug] [INST] 2015-03-23 22:29:43 +0000 Debug: Got new command 2 from instruments: au.mainApp().getTreeForXML()
info: [debug] [INST] 2015-03-23 22:29:43 +0000 Debug: evaluating au.mainApp().getTreeForXML()
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.3.6","revision":"004f52f249d3513809e7d0734d9205d1fec19f8e"},"isShuttingDown":false},"sessionId":"86e71593-3f35-4cbb-a7d4-a53b0eb38a4d"}

所以,au.mainApp().getTreeForXML() 没有被及时评估。如果我从 init 中删除 autoAcceptAlerts 参数,我需要手动关闭警报,但评估会在一秒钟左右后进行,并且测试运行良好。

也许有人偶然发现了类似的问题,并对正在发生的事情有所了解?真的很感激。

【问题讨论】:

    标签: c# ios appium ios-ui-automation ui-testing


    【解决方案1】:

    经过一段时间的反复试验,我更换了

    capabilities.SetCapability("autoAcceptAlerts", true);
    driver = new IOSDriver(new Uri("my-appium-URL"), capabilities);
    

    driver = new IOSDriver(new Uri("my-appium-URL"), capabilities);
    driver.SwitchTo().Alert().Accept();
    

    一切正常。不过,很高兴知道为什么 autoAcceptAlerts 会导致这个问题,但现在我很高兴。

    【讨论】:

      猜你喜欢
      • 2016-08-03
      • 2017-11-07
      • 1970-01-01
      • 1970-01-01
      • 2017-03-23
      • 2015-05-13
      • 1970-01-01
      • 1970-01-01
      • 2013-10-31
      相关资源
      最近更新 更多