Reputation: 51
I'm using Appium 1.3.6 on Mac OS X, and writing my tests in C#. I've added autoAcceptAlerts capability parameter to my test init, so it looks like this:
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.");
And after adding it, I can only successfully launch test only occasionally. Most of the time I see app is launched, alert is closed, main activity shows, but then test fails. What I see in the logs is:
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.
And from Appium log:
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"}
So, au.mainApp().getTreeForXML() is not being evaluated in time. If I remove autoAcceptAlerts parameter from init, I need to close alert manually, but evaluation happens just after a second or so, and test runs fine.
Maybe someone stumbled upon similar problem and has some kind of insight about what's going on? Would really appreciate that.
Upvotes: 1
Views: 1895
Reputation: 51
After quite some time of trial and errors I replaced
capabilities.SetCapability("autoAcceptAlerts", true);
driver = new IOSDriver(new Uri("my-appium-URL"), capabilities);
with
driver = new IOSDriver(new Uri("my-appium-URL"), capabilities);
driver.SwitchTo().Alert().Accept();
And everything works fine. Still, it would be nice to know why autoAcceptAlerts causes this problem, but for now I'm pretty happy.
Upvotes: 2