质量保证金 |无法使用 appiumDriver 连接到 ExperiTest 或 pCloudy,但我只能使用 appiumRemoteDriver 连接
QAF | Not able to connect to ExperiTest or pCloudy with appiumDriver but I can connect only with appiumRemoteDriver
我正在使用 switchDriver('appiumRemoteDriver') 和 switchDriver('chromeRemoteDriver') 在同一场景中连接 Web 和移动设备。
我无法使用 switchDriver("appiumDriver") / switchDriver("iosDriver") / switchDriver("androidDriver") 连接 ExperiTest 或 pCloudy。
我在使用 appiumRemoteDriver 时遇到的问题之一是我无法通过常见步骤使用 QAF 的移动支持包,或者无法执行自定义命令。例如:
AppiumDriver driver = (AppiumDriver) new WebDriverTestBase().getDriver().getUnderLayingDriver();
String allElements = driver.getPageSource();
我尝试过的另一种选择:
String allElements = (String) new WebDriverTestBase().getDriver().getPageSource();
System.out.println("=== Mobile ELEMENTS === : " + allElements);
使用上述命令时出现的错误:
Session ID: ba205277-ae7b-452d-905d-88df4231ce09
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_212]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_212]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185) ~[selenium-remote-driver-3.6.0.jar:?]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120) ~[selenium-remote-driver-3.6.0.jar:?]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) ~[selenium-remote-driver-3.6.0.jar:?]
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164) ~[selenium-remote-driver-3.6.0.jar:?]
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586) ~[selenium-remote-driver-3.6.0.jar:?]
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.execute(QAFExtendedWebDriver.java:236) ~[qaf-3.0.1.jar:?]
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:643) ~[selenium-remote-driver-3.6.0.jar:?]
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.execute(QAFExtendedWebDriver.java:224) ~[qaf-3.0.1.jar:?]
at org.openqa.selenium.remote.RemoteWebDriver.getPageSource(RemoteWebDriver.java:468) ~[selenium-remote-driver-3.6.0.jar:?]
at com.rt.steps.rt_globals.iGetAllElements(rt_globals.java:3103) ~[test-classes/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at com.qmetry.qaf.automation.step.JavaStep.doExecute(JavaStep.java:150) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.BaseTestStep.execute(BaseTestStep.java:149) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.StringTestStep.execute(StringTestStep.java:127) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.client.Scenario.execute(Scenario.java:174) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.client.Scenario.scenario(Scenario.java:237) [qaf-3.0.1.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177) [testng-6.10.jar:?]
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) [testng-6.10.jar:?]
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) [testng-6.10.jar:?]
at org.testng.TestRunner.privateRun(TestRunner.java:756) [testng-6.10.jar:?]
at org.testng.TestRunner.run(TestRunner.java:610) [testng-6.10.jar:?]
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387) [testng-6.10.jar:?]
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382) [testng-6.10.jar:?]
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) [testng-6.10.jar:?]
at org.testng.SuiteRunner.run(SuiteRunner.java:289) [testng-6.10.jar:?]
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) [testng-6.10.jar:?]
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) [testng-6.10.jar:?]
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293) [testng-6.10.jar:?]
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218) [testng-6.10.jar:?]
at org.testng.TestNG.runSuites(TestNG.java:1133) [testng-6.10.jar:?]
at org.testng.TestNG.run(TestNG.java:1104) [testng-6.10.jar:?]
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:122) [surefire-testng-2.9.jar:2.9]
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) [surefire-testng-2.9.jar:2.9]
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101) [surefire-testng-2.9.jar:2.9]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) [surefire-api-2.9.jar:2.9]
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70) [surefire-booter-2.9.jar:2.9]
msg >>Method is not implemented
我在一些帖子中读到,最好使用 iosDriver 或 appiumDriver 来访问驱动程序实例。
来自 link:https://github.com/qmetry/qaf/issues/167
注意:driverClass 功能不适用于远程驱动程序,因此如果您提供驱动程序名称 appiumRemoteDriver 驱动程序 class 将不会被考虑,您将在上述语句中得到 class 强制转换异常。
以下命令有效:
String drivername = TestBaseProvider.instance().get().getDriverName();
System.out.println(drivername);
// This is printing "appiumRemoteDriver"
String driverClassname = new WebDriverTestBase().getDriver().getUnderLayingDriver().getClass().getSimpleName();
System.out.println(driverClassname);
// This is printing "QAFExtendedWebDriver"
************** 更新信息 ****************************
使用 appiumDriver 时出错:
org.openqa.selenium.TimeoutException: Timed out after 0 seconds: Unable to create driver instance in 1st attempt with retry timeout of 30000 seconds. You can check/set value of 'driver.init.retry.timeout' appropriately to set retry timeout on driver initialization failure.
at com.qmetry.qaf.automation.ui.util.DynamicWait.until(DynamicWait.java:168) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase.init(QAFTestBase.java:478) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase.getUiDriver(QAFTestBase.java:253) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.WebDriverTestBase.getDriver(WebDriverTestBase.java:44) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebElement.<init>(QAFExtendedWebElement.java:132) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebElement.<init>(QAFExtendedWebElement.java:142) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.webdriver.ElementFactory.$(ElementFactory.java:173) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.CommonStep.sendKeys_aroundBody6(CommonStep.java:114) ~[qaf-support-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.CommonStep$AjcClosure7.run(CommonStep.java:1) ~[qaf-support-3.0.1.jar:?]
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:167) ~[aspectjrt-1.9.5.jar:?]
at com.qmetry.qaf.automation.step.JavaStepReporter.javaTestStep(JavaStepReporter.java:93) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.CommonStep.sendKeys(CommonStep.java:113) ~[qaf-support-3.0.1.jar:?]
at com.rt.steps.rt_globals.iFillInTo(rt_globals.java:815) ~[test-classes/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at com.qmetry.qaf.automation.step.JavaStep.doExecute(JavaStep.java:150) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.BaseTestStep.execute(BaseTestStep.java:149) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.StringTestStep.execute(StringTestStep.java:127) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.client.Scenario.execute(Scenario.java:174) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.client.Scenario.scenario(Scenario.java:237) [qaf-3.0.1.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177) [testng-6.10.jar:?]
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) [testng-6.10.jar:?]
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) [testng-6.10.jar:?]
at org.testng.TestRunner.privateRun(TestRunner.java:756) [testng-6.10.jar:?]
at org.testng.TestRunner.run(TestRunner.java:610) [testng-6.10.jar:?]
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387) [testng-6.10.jar:?]
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382) [testng-6.10.jar:?]
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) [testng-6.10.jar:?]
at org.testng.SuiteRunner.run(SuiteRunner.java:289) [testng-6.10.jar:?]
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) [testng-6.10.jar:?]
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) [testng-6.10.jar:?]
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293) [testng-6.10.jar:?]
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218) [testng-6.10.jar:?]
at org.testng.TestNG.runSuites(TestNG.java:1133) [testng-6.10.jar:?]
at org.testng.TestNG.run(TestNG.java:1104) [testng-6.10.jar:?]
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:122) [surefire-testng-2.9.jar:2.9]
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) [surefire-testng-2.9.jar:2.9]
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101) [surefire-testng-2.9.jar:2.9]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) [surefire-api-2.9.jar:2.9]
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70) [surefire-booter-2.9.jar:2.9]
Caused by: org.openqa.selenium.WebDriverException: Unable to create driver instance in 1st attempt with retry timeout of 30000 seconds. You can check/set value of 'driver.init.retry.timeout' appropriately to set retry timeout on driver initialization failure.
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:572) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:1) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.util.DynamicWait.until(DynamicWait.java:147) ~[qaf-3.0.1.jar:?]
... 55 more
Caused by: org.openqa.selenium.WebDriverException: java.lang.NoSuchMethodError: org.openqa.selenium.remote.http.HttpClient$Factory.createDefault()Lorg/openqa/selenium/remote/http/HttpClient$Factory;
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'MAVLT1059', ip: 'fe80:0:0:0:10fb:ea81:8051:cf0c%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.5', java.version: '1.8.0_212'
Driver info: driver.version: unknown
at com.qmetry.qaf.automation.ui.UiDriverFactory.getDriverObj(UiDriverFactory.java:256) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.access(UiDriverFactory.java:234) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory$Browsers.getDriver(UiDriverFactory.java:418) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory$Browsers.access(UiDriverFactory.java:407) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.getDriver(UiDriverFactory.java:214) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.get(UiDriverFactory.java:87) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:568) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:1) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.util.DynamicWait.until(DynamicWait.java:147) ~[qaf-3.0.1.jar:?]
... 55 more
Caused by: java.lang.NoSuchMethodError: org.openqa.selenium.remote.http.HttpClient$Factory.createDefault()Lorg/openqa/selenium/remote/http/HttpClient$Factory;
at io.appium.java_client.remote.AppiumCommandExecutor.<init>(AppiumCommandExecutor.java:96) ~[java-client-7.4.1.jar:?]
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:98) ~[java-client-7.4.1.jar:?]
at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:90) ~[java-client-7.4.1.jar:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_212]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_212]
at com.qmetry.qaf.automation.ui.UiDriverFactory.getDriverObj(UiDriverFactory.java:254) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.access(UiDriverFactory.java:234) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory$Browsers.getDriver(UiDriverFactory.java:418) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory$Browsers.access(UiDriverFactory.java:407) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.getDriver(UiDriverFactory.java:214) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.get(UiDriverFactory.java:87) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:568) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:1) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.util.DynamicWait.until(DynamicWait.java:147) ~[qaf-3.0.1.jar:?]
... 55 more
msg >>Timed out after 0 seconds: Unable to create driver instance in 1st attempt with retry timeout of 30000 seconds. You can check/set value of 'driver.init.retry.timeout' appropriately to set retry timeout on driver initialization failure.
从 driver.name
中删除 remote
。而不是使用值 appiumRemoteDriver
使用 appiumDriver
并设置 driverClass
能力。
使用云服务提供商提供的云集 url 中的设备作为 remote.server
.
的值
例如:
remote.server=<url provided by cloud service provider>
对于ios
driver.name=appiumDriver
#for ios set driverClass IOSDriver
appium.capabilities.driverClass=io.appium.java_client.ios.IOSDriver
# you can use more meaningful name as well like below
driver.name=iosDriver
ios.capabilities.driverClass=io.appium.java_client.ios.IOSDriver
对于android
driver.name=appiumDriver
#for android set driverClass AndroidDriver
appium.capabilities.driverClass=io.appium.java_client.android.AndroidDriver
# you can use more meaningful name as well like below
driver.name=androidDriver
android.capabilities.driverClass=io.appium.java_client.android.AndroidDriver
参考setting driver capabilities了解更多详情。
我正在使用 switchDriver('appiumRemoteDriver') 和 switchDriver('chromeRemoteDriver') 在同一场景中连接 Web 和移动设备。
我无法使用 switchDriver("appiumDriver") / switchDriver("iosDriver") / switchDriver("androidDriver") 连接 ExperiTest 或 pCloudy。
我在使用 appiumRemoteDriver 时遇到的问题之一是我无法通过常见步骤使用 QAF 的移动支持包,或者无法执行自定义命令。例如:
AppiumDriver driver = (AppiumDriver) new WebDriverTestBase().getDriver().getUnderLayingDriver();
String allElements = driver.getPageSource();
我尝试过的另一种选择:
String allElements = (String) new WebDriverTestBase().getDriver().getPageSource();
System.out.println("=== Mobile ELEMENTS === : " + allElements);
使用上述命令时出现的错误:
Session ID: ba205277-ae7b-452d-905d-88df4231ce09
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_212]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_212]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185) ~[selenium-remote-driver-3.6.0.jar:?]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120) ~[selenium-remote-driver-3.6.0.jar:?]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) ~[selenium-remote-driver-3.6.0.jar:?]
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164) ~[selenium-remote-driver-3.6.0.jar:?]
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586) ~[selenium-remote-driver-3.6.0.jar:?]
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.execute(QAFExtendedWebDriver.java:236) ~[qaf-3.0.1.jar:?]
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:643) ~[selenium-remote-driver-3.6.0.jar:?]
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.execute(QAFExtendedWebDriver.java:224) ~[qaf-3.0.1.jar:?]
at org.openqa.selenium.remote.RemoteWebDriver.getPageSource(RemoteWebDriver.java:468) ~[selenium-remote-driver-3.6.0.jar:?]
at com.rt.steps.rt_globals.iGetAllElements(rt_globals.java:3103) ~[test-classes/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at com.qmetry.qaf.automation.step.JavaStep.doExecute(JavaStep.java:150) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.BaseTestStep.execute(BaseTestStep.java:149) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.StringTestStep.execute(StringTestStep.java:127) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.client.Scenario.execute(Scenario.java:174) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.client.Scenario.scenario(Scenario.java:237) [qaf-3.0.1.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177) [testng-6.10.jar:?]
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) [testng-6.10.jar:?]
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) [testng-6.10.jar:?]
at org.testng.TestRunner.privateRun(TestRunner.java:756) [testng-6.10.jar:?]
at org.testng.TestRunner.run(TestRunner.java:610) [testng-6.10.jar:?]
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387) [testng-6.10.jar:?]
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382) [testng-6.10.jar:?]
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) [testng-6.10.jar:?]
at org.testng.SuiteRunner.run(SuiteRunner.java:289) [testng-6.10.jar:?]
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) [testng-6.10.jar:?]
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) [testng-6.10.jar:?]
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293) [testng-6.10.jar:?]
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218) [testng-6.10.jar:?]
at org.testng.TestNG.runSuites(TestNG.java:1133) [testng-6.10.jar:?]
at org.testng.TestNG.run(TestNG.java:1104) [testng-6.10.jar:?]
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:122) [surefire-testng-2.9.jar:2.9]
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) [surefire-testng-2.9.jar:2.9]
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101) [surefire-testng-2.9.jar:2.9]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) [surefire-api-2.9.jar:2.9]
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70) [surefire-booter-2.9.jar:2.9]
msg >>Method is not implemented
我在一些帖子中读到,最好使用 iosDriver 或 appiumDriver 来访问驱动程序实例。
来自 link:https://github.com/qmetry/qaf/issues/167 注意:driverClass 功能不适用于远程驱动程序,因此如果您提供驱动程序名称 appiumRemoteDriver 驱动程序 class 将不会被考虑,您将在上述语句中得到 class 强制转换异常。
以下命令有效:
String drivername = TestBaseProvider.instance().get().getDriverName();
System.out.println(drivername);
// This is printing "appiumRemoteDriver"
String driverClassname = new WebDriverTestBase().getDriver().getUnderLayingDriver().getClass().getSimpleName();
System.out.println(driverClassname);
// This is printing "QAFExtendedWebDriver"
************** 更新信息 ****************************
使用 appiumDriver 时出错:
org.openqa.selenium.TimeoutException: Timed out after 0 seconds: Unable to create driver instance in 1st attempt with retry timeout of 30000 seconds. You can check/set value of 'driver.init.retry.timeout' appropriately to set retry timeout on driver initialization failure.
at com.qmetry.qaf.automation.ui.util.DynamicWait.until(DynamicWait.java:168) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase.init(QAFTestBase.java:478) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase.getUiDriver(QAFTestBase.java:253) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.WebDriverTestBase.getDriver(WebDriverTestBase.java:44) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebElement.<init>(QAFExtendedWebElement.java:132) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebElement.<init>(QAFExtendedWebElement.java:142) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.webdriver.ElementFactory.$(ElementFactory.java:173) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.CommonStep.sendKeys_aroundBody6(CommonStep.java:114) ~[qaf-support-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.CommonStep$AjcClosure7.run(CommonStep.java:1) ~[qaf-support-3.0.1.jar:?]
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:167) ~[aspectjrt-1.9.5.jar:?]
at com.qmetry.qaf.automation.step.JavaStepReporter.javaTestStep(JavaStepReporter.java:93) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.CommonStep.sendKeys(CommonStep.java:113) ~[qaf-support-3.0.1.jar:?]
at com.rt.steps.rt_globals.iFillInTo(rt_globals.java:815) ~[test-classes/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at com.qmetry.qaf.automation.step.JavaStep.doExecute(JavaStep.java:150) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.BaseTestStep.execute(BaseTestStep.java:149) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.StringTestStep.execute(StringTestStep.java:127) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.client.Scenario.execute(Scenario.java:174) [qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.step.client.Scenario.scenario(Scenario.java:237) [qaf-3.0.1.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851) [testng-6.10.jar:?]
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177) [testng-6.10.jar:?]
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) [testng-6.10.jar:?]
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) [testng-6.10.jar:?]
at org.testng.TestRunner.privateRun(TestRunner.java:756) [testng-6.10.jar:?]
at org.testng.TestRunner.run(TestRunner.java:610) [testng-6.10.jar:?]
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387) [testng-6.10.jar:?]
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382) [testng-6.10.jar:?]
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) [testng-6.10.jar:?]
at org.testng.SuiteRunner.run(SuiteRunner.java:289) [testng-6.10.jar:?]
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) [testng-6.10.jar:?]
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) [testng-6.10.jar:?]
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293) [testng-6.10.jar:?]
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218) [testng-6.10.jar:?]
at org.testng.TestNG.runSuites(TestNG.java:1133) [testng-6.10.jar:?]
at org.testng.TestNG.run(TestNG.java:1104) [testng-6.10.jar:?]
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:122) [surefire-testng-2.9.jar:2.9]
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) [surefire-testng-2.9.jar:2.9]
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101) [surefire-testng-2.9.jar:2.9]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) [surefire-api-2.9.jar:2.9]
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104) [surefire-booter-2.9.jar:2.9]
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70) [surefire-booter-2.9.jar:2.9]
Caused by: org.openqa.selenium.WebDriverException: Unable to create driver instance in 1st attempt with retry timeout of 30000 seconds. You can check/set value of 'driver.init.retry.timeout' appropriately to set retry timeout on driver initialization failure.
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:572) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:1) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.util.DynamicWait.until(DynamicWait.java:147) ~[qaf-3.0.1.jar:?]
... 55 more
Caused by: org.openqa.selenium.WebDriverException: java.lang.NoSuchMethodError: org.openqa.selenium.remote.http.HttpClient$Factory.createDefault()Lorg/openqa/selenium/remote/http/HttpClient$Factory;
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'MAVLT1059', ip: 'fe80:0:0:0:10fb:ea81:8051:cf0c%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.5', java.version: '1.8.0_212'
Driver info: driver.version: unknown
at com.qmetry.qaf.automation.ui.UiDriverFactory.getDriverObj(UiDriverFactory.java:256) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.access(UiDriverFactory.java:234) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory$Browsers.getDriver(UiDriverFactory.java:418) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory$Browsers.access(UiDriverFactory.java:407) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.getDriver(UiDriverFactory.java:214) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.get(UiDriverFactory.java:87) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:568) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:1) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.util.DynamicWait.until(DynamicWait.java:147) ~[qaf-3.0.1.jar:?]
... 55 more
Caused by: java.lang.NoSuchMethodError: org.openqa.selenium.remote.http.HttpClient$Factory.createDefault()Lorg/openqa/selenium/remote/http/HttpClient$Factory;
at io.appium.java_client.remote.AppiumCommandExecutor.<init>(AppiumCommandExecutor.java:96) ~[java-client-7.4.1.jar:?]
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:98) ~[java-client-7.4.1.jar:?]
at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:90) ~[java-client-7.4.1.jar:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_212]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_212]
at com.qmetry.qaf.automation.ui.UiDriverFactory.getDriverObj(UiDriverFactory.java:254) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.access(UiDriverFactory.java:234) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory$Browsers.getDriver(UiDriverFactory.java:418) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory$Browsers.access(UiDriverFactory.java:407) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.getDriver(UiDriverFactory.java:214) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.UiDriverFactory.get(UiDriverFactory.java:87) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:568) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.core.QAFTestBase$DriverInitExpectedCondition.apply(QAFTestBase.java:1) ~[qaf-3.0.1.jar:?]
at com.qmetry.qaf.automation.ui.util.DynamicWait.until(DynamicWait.java:147) ~[qaf-3.0.1.jar:?]
... 55 more
msg >>Timed out after 0 seconds: Unable to create driver instance in 1st attempt with retry timeout of 30000 seconds. You can check/set value of 'driver.init.retry.timeout' appropriately to set retry timeout on driver initialization failure.
从 driver.name
中删除 remote
。而不是使用值 appiumRemoteDriver
使用 appiumDriver
并设置 driverClass
能力。
使用云服务提供商提供的云集 url 中的设备作为 remote.server
.
例如:
remote.server=<url provided by cloud service provider>
对于ios
driver.name=appiumDriver
#for ios set driverClass IOSDriver
appium.capabilities.driverClass=io.appium.java_client.ios.IOSDriver
# you can use more meaningful name as well like below
driver.name=iosDriver
ios.capabilities.driverClass=io.appium.java_client.ios.IOSDriver
对于android
driver.name=appiumDriver
#for android set driverClass AndroidDriver
appium.capabilities.driverClass=io.appium.java_client.android.AndroidDriver
# you can use more meaningful name as well like below
driver.name=androidDriver
android.capabilities.driverClass=io.appium.java_client.android.AndroidDriver
参考setting driver capabilities了解更多详情。