我看到控制台'驱动程序为null'执行测试脚本后出错
脚本:
capabilities.setCapability("appium-version", "1.4.0");
System.out.println("<<< Detects android device / emulator >>>");
capabilities.setCapability("deviceName","New1");
capabilities.setCapability("platformVersion", "4.4.2");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("autoWebview","true");
capabilities.setCapability("automationName","Appium");
//capabilities.setCapability("newCommandTimeout", "180");
capabilities.setCapability("app", "com.android.launcher");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appActivity", "com.sciit.mat");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
控制台错误:
<<< Detects android device / emulator >>>
<<< Utlizes remote webdriver >>>
Driver in App screen : null
FAILED: sampletestmethod
java.lang.NoSuchMethodError: org.openqa.selenium.remote.ErrorHandler.<init>(Lorg/openqa/selenium/remote/ErrorCodes;Z)V
at io.appium.java_client.AppiumDriver.<clinit>(AppiumDriver.java:46)
at com.sci.matapp.sampleScript1.TestScript1.sampletestmethod(TestScript1.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:773)
at org.testng.TestRunner.run(TestRunner.java:623)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1018)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.XMLReporter@1064425: 521 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@6ea0c6: 508 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 131 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@899482: 746 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@d17bee: 551 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@16432db: 81 ms
注意:我使用了以下jar文件:
硒的Java-2.47.1
java client2.2.0
硒 - Java的客户机驱动器-1.0.1
硒 - 服务器 - 独立-2.47.1
如果我错过了什么,可以帮助一些人。 谢谢,
答案 0 :(得分:0)
当jar文件之间存在版本冲突时,会出现classNotFoundException / NoSuchMethodError。 同时查看异常,它在AppiumDriver上给出了错误。
修改强>
确保您使用最新版本的httpclient&amp;的HttpCore。
尝试使用所有jar的最新版本,以避免主要NoSuchMethodError
在给定上下文中找不到元素的Edit2 您需要明确切换到webview,以便appium可以查找元素。 尝试获取以下所有网络视图:
String nr = driver.getWindowHandles().toString();
System.out.print(nr);
IT会返回一个类似于:
的数组[NATIVE_APP, WEBVIEW_1, WEBVIEW_0]
现在切换到WEBVIEW_1:
driver.switchTo().window("WEBVIEW_1");
请注意:Appium不适合在多个网页浏览之间切换。 (至少我遇到了这个问题。)