seleniumappiumappium-androidappium-iosqaf

QAF | Not able to connect to ExperiTest or pCloudy with appiumDriver but I can connect only with appiumRemoteDriver


I'm using switchDriver('appiumRemoteDriver') & switchDriver('chromeRemoteDriver') to connect between Web and mobile within the same scenario.

I'm not able to use switchDriver("appiumDriver") / switchDriver("iosDriver") / switchDriver("androidDriver") to connect with ExperiTest or pCloudy.

One of the issues I'm facing by using appiumRemoteDriver is that I'm not able to use QAF's mobile-support pack with common steps or are not able to execute custom commands. Eg:

AppiumDriver driver = (AppiumDriver) new WebDriverTestBase().getDriver().getUnderLayingDriver();
String allElements = driver.getPageSource();

Another option I have tried:

String allElements = (String) new WebDriverTestBase().getDriver().getPageSource();
System.out.println("=== Mobile ELEMENTS === : " + allElements);

The error I get when I use above commands:

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

I have read in some posts that it is better to use iosDriver or appiumDriver to get access to the driver instance.

From link: https://github.com/qmetry/qaf/issues/167 NOTE: driverClass capability will not applicable with remote driver, so if you provide driver name appiumRemoteDriver driver class will not be considered and you will get class cast exception in the above statement.

Below commands are working:

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"

************** UPDATE INFO ****************************

Error in using 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$4(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$5(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$4(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$5(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.

Solution

  • Remove remote from driver.name. Instead of using value appiumRemoteDriver use appiumDriver and set driverClass capability. To use device from cloud set url provided by cloud service provider as value of remote.server.

    For example:

    remote.server=<url provided by cloud service provider>
    

    For 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
    
    

    For 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
    
    

    Refer setting driver capabilities for more details.