gpt4 book ai didi

c# - 无法使用 autoAcceptAlerts 在 iOS 上运行 Appium 测试

转载 作者:行者123 更新时间:2023-11-29 12:25:42 25 4
gpt4 key购买 nike

我在 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 参数,我需要手动关闭警报,但评估会在一秒左右后发生,测试运行正常。

也许有人偶然发现了类似的问题并且对正在发生的事情有某种洞察力?非常感谢。

最佳答案

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

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 会导致此问题,但现在我很高兴。

关于c# - 无法使用 autoAcceptAlerts 在 iOS 上运行 Appium 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29221735/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com