【发布时间】:2018-10-14 18:31:44
【问题描述】:
我的测试需要打开和关闭通知面板,然后从 Android 设备(Moto G4 Android 7 - AWS 设备场)返回应用程序。所以我在我的测试中调用了以下方法
androidActivity.openAndCloseNotifications();
在哪里
public void openAndCloseNotifications() throws InterruptedException{
TimeUnit.SECONDS.sleep(3);
driver.openNotifications();
TimeUnit.SECONDS.sleep(3);
driver.pressKeyCode(AndroidKeyCode.BACK);
}
测试通过设备在本地通过,但是当我在 AWS 设备场上运行它时,我可以看到通知面板永远不会打开,因此测试失败。 此时 AWS 设备场是否允许与通知面板交互?如果没有,我该如何处理?因为这对于我们的大多数测试来说都是一个问题。 提前致谢!
这是失败的测试,在androidActivity.openAndCloseNotifications(); 行失败:
public boolean run() throws Exception {
MainActivity mainActivity = new MainActivity(driver);
AndroidActivity androidActivity = new AndroidActivity(driver);
LoginActivity loginActivity = new LoginActivity(driver);
try {
if(device.getCapability("manufacturer")=="Huawei")
{
driver.closeApp();
driver.launchApp();
loginActivity.registerApp("whateverhere");
androidActivity.openAndCloseNotifications();
mainActivity.verifyAppIsReady();
assertTrue(mainActivity.check());
return true;
}
else {
driver.closeApp();
driver.launchApp();
loginActivity.registerApp("whateverhere");
androidActivity.openAndCloseNotifications();
mainActivity.verifyAppIsReady();
System.out.println("Verified Stop button is displayed");
assertTrue(mainActivity.check());
System.out.println("Verified title is displayed");
return true;
}
}
catch(Exception e) {
System.out.println(e);
return false;
}
}
来自 AWS 设备场的日志(本地没有故障) java.lang.AssertionError: 预期 [true] 但发现 [false]\n\tat org.testng.Assert.fail(Assert.java:94)\n\tat org.testng.Assert.failNotEquals(Assert.java:494 )\n\tat org.testng.Assert.assertTrue(Assert.java:42)\n\tat org.testng.Assert.assertTrue(Assert.java:52)\n\tat com.OneMeter.Robirdo.TestSequence1.test1 (TestSequence1.java:48)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl。调用(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)\n \tat org.testng.internal.Invoker.invokeMethod(Invoker.java:714)\n\tat org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)\n\tat org.testng.internal.Invoker。 invokeTestMethods(Invoker.java:1231)\n\tat org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodW orker.java:127)\n\tat org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)\n\tat org.testng.TestRunner.privateRun(TestRunner.java:767)\n\tat org. testng.TestRunner.run(TestRunner.java:617)\n\tat org.testng.SuiteRunner.runTest(SuiteRunner.java:348)\n\tat org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)\n \tat org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)\n\tat org.testng.SuiteRunner.run(SuiteRunner.java:254)\n\tat org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java: 52)\n\tat org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)\n\tat org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)\n\tat org.testng.TestNG.runSuitesLocally( TestNG.java:1149)\n\tat org.testng.TestNG.run(TestNG.java:1057)\n\tat org.testng.TestNG.privateMain(TestNG.java:1364)\n\tat org.testng。 TestNG.main(TestNG.java:1333)\n\n
【问题讨论】:
-
能否提供appium服务器日志和打印页面源的测试输出?
-
我已经添加了您要求的所有内容。本地一切都很好。
-
还应该有来自 Device Farm 的 appum 服务器输出日志。您也可以使用该日志更新它吗?它将显示调用 openNotifications 方法时究竟发生了什么。