Serenity-core: Unable to do Appium Touchaction in Serenity

Created on 16 Mar 2016  Â·  14Comments  Â·  Source: serenity-bdd/serenity-core

Hi,
Im using Appium+Serernity+JBehave for an Android automation. When trying for
TouchAction actions = new TouchAction((MobileDriver) getDriver()); in an PageObject class the following error is being shown.

My Environment is
Serenity-core: 1.1.29-rc.1
Serenity-jbehave: 1.8.0
Win: 8.1 pro
Eclipse: Version: Mars.2 Release (4.5.2)
Appium version: 1.4.16.1 (Ophiuchus)

(java.lang.ClassCastException: net.thucydides.core.webdriver.WebDriverFacade cannot be cast to io.appium.java_client.MobileDriver)

java.lang.ClassCastException: net.thucydides.core.webdriver.WebDriverFacade cannot be cast to io.appium.java_client.MobileDriver
at com.test.appium.RealBucksAutomation.pageobject.RealbuckPageObject.clickTextBox(MyClassPageObject.java:47)
at com.test.appium.RealBucksAutomation.model.RealbuckTestStepModules.clickOntextbox(MyClassStepModules.java:17)
at com.test.appium.RealBucksAutomation.model.RealbuckTestStepModules$$EnhancerByCGLIB$$a9d424f2.CGLIB$clickOntextbox$1()
at com.test.appium.RealBucksAutomation.model.RealbuckTestStepModules$$EnhancerByCGLIB$$a9d424f2$$FastClassByCGLIB$$54e5228d.invoke()
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:348)
at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:333)
at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:308)
at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:130)
at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:57)
at com.test.appium.RealBucksAutomation.model.RealbuckTestStepModules$$EnhancerByCGLIB$$a9d424f2.clickOntextbox()
at com.test.appium.RealBucksAutomation.steps.RealbuckTestSteps.givenIClickOnTheTextBox(MyClassTestSteps.java:14)
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.jbehave.core.steps.StepCreator$ParametrisedStep.perform(StepCreator.java:599)
at org.jbehave.core.embedder.PerformableTree$FineSoFar.run(PerformableTree.java:340)

bug waiting for feedback

All 14 comments

@selvavaithi thanks, for this issue!

WebDriver facade should be updated to implement MobileDriver as well.

Please try to run something like (I think you will lost some statistics until we will fix this bug):
WebDriver facade = getDriver();
WebDriver driver = ((WebDriverFacade)facade).getDriver();
TouchAction actions = new TouchAction((MobileDriver)driver) ;

Hi @YamStranger Sorry when trying your code getting this error

"The method getDriver() is undefined for the type WebDriverFacade"

@selvavaithi were you able to get this working?

Hi @wakaleo
Yes now I can able to get this working. Thanks

Can you please let me know how did you get this working? I am running into same problem, Any sample code is appreciated.

@divyaramachandran
This is how i did it.
WebDriver facade = getDriver();
WebDriver driver= ((WebDriverFacade) facade).getProxiedDriver();
TouchAction actions = new TouchAction((MobileDriver)driver) ;

Thank you Selva, but I get a different error like the below if I use as below

WebDriver driver = getDriver();

WebDriver driver1 = ((WebDriverFacade) driver).getProxiedDriver();

TouchAction tAction1 = new TouchAction((MobileDriver)driver1) ;

Error in this code ::: tAction1.moveTo(element).release().perform();

java.lang.ClassCastException: com.sun.proxy.$Proxy19 cannot be cast to org.openqa.selenium.remote.RemoteWebElement

While performing actions I get the error

Thanks & regards,

Divya

From: Selva Kumar V <[email protected]notifications@github.com>
Reply-To: serenity-bdd/serenity-core <[email protected]reply@reply.github.com>
Date: Friday, 22 July 2016 at 4:13 PM
To: serenity-bdd/serenity-core <[email protected]serenity-core@noreply.github.com>
Cc: Divya Ramachandran <[email protected]divyaramachandran@ge.com>, Mention <[email protected]mention@noreply.github.com>
Subject: EXT: Re: [serenity-bdd/serenity-core] Unable to do Appium Touchaction in Serenity (#362)

@divyaramachandranhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_divyaramachandran&d=CwMCaQ&c=IV_clAzoPDE253xZdHuilRgztyh_RiV3wUrLrDQYWSI&r=JMDl_mfJZdK3AMCRN1bkFXj8fHggzdLRiMloH1-OaDQ&m=ELsnJHb1fHpwBIPRMDmcPspdSRy9RWqkE4CmhWyPz8U&s=eEHhFJgrWvwgDpfQlz9--sk4_t36fgw8SfM3eL1TmDo&e=
This is how i did it.
WebDriver facade = getDriver();
WebDriver driver= ((WebDriverFacade) facade).getProxiedDriver();
TouchAction actions = new TouchAction((MobileDriver)driver) ;

�
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_serenity-2Dbdd_serenity-2Dcore_issues_362-23issuecomment-2D234513191&d=CwMCaQ&c=IV_clAzoPDE253xZdHuilRgztyh_RiV3wUrLrDQYWSI&r=JMDl_mfJZdK3AMCRN1bkFXj8fHggzdLRiMloH1-OaDQ&m=ELsnJHb1fHpwBIPRMDmcPspdSRy9RWqkE4CmhWyPz8U&s=6JSN-rbCV7i75fIb5GFrUIUFRqp_UyXFmEp5Rqs37Cc&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ATcvISnsCnjrlAA5lSGuK1jLs7dBiXzlks5qYJ7igaJpZM4Hx2yP&d=CwMCaQ&c=IV_clAzoPDE253xZdHuilRgztyh_RiV3wUrLrDQYWSI&r=JMDl_mfJZdK3AMCRN1bkFXj8fHggzdLRiMloH1-OaDQ&m=ELsnJHb1fHpwBIPRMDmcPspdSRy9RWqkE4CmhWyPz8U&s=Tv3dq2yhQ8ZZS1fP5J_h2LHKI1aqh9t3KhDLi39i8TM&e=.

@selvavaithi

I tried your way, but was getting below error :

Error:-

Error:org.openqa.selenium.remote.RemoteWebDriver$$EnhancerByCGLIB$$6191bd78 cannot be cast to io.appium.java_client.MobileDriver

Please Note : - I am running test on saucelabs.

Could you please provide a solution to it. Many thanks in advance

Thanks,
Lovesh Jain

Yes I am also getting the same error while running this on sauce labs. it works fine when running it on the simulator on local machine but gives cannot be cast to io.appium.java_client.MobileDriver on Sauce Labs. Please Help

Many Thanks in advance

Charan

@charansethi1

Hi Charan,

I have raised a separate issue with @wakaleo and waiting for a perfect solution but meanwhile I was able to resolve the issue with an alternative solution.

The issue is that when you run the test on saucelabs and give serenity property "Saucelabs.url=something" then the driver is considered as RemoteWebdriver and remotedriver cannot be cast to other driver. So to resolve the issue don't provide Saucelabs.url property and run the test. The only issue you would get is serenity report won't be having your saucelabs job video link because the SaucelabsLinkGenerator.class take saucelabs.url for providing saucelabs video link in serenity report. Therefore you can modify the function with below function to take Saucelab_Access_key : -

private boolean saucelabsIsNotConfigured() {
return (ThucydidesSystemProperty.SAUCELABS_ACCESS_KEY.from(environmentVariables) == null);
}

Also having said that you will encounter 1 issue after this which is when your test case fails, serenity will try to take a screenshot if you have set "serenity.take.screenshots=FOR_FAILURES" or "serenity.take.screenshots=AFTER_EACH_STEP" but since we are not providing saucelabs.url property, it does not consider that as RemoteDriver and does not go to takeScreenShot function of RemoteDriver and because of that your test case will try to do that till saucelabs job time which is by default 30 mins comes to end. I would recommend you to set "serenity.take.screenshots=DISABLED".

Let me know if in case you face any issue.

Thanks,
Lovesh Jain
+642108258442

Hi Lovesh

Thanks for the reply. Can you please explain me How and where to use the function you have mentioned

private boolean saucelabsIsNotConfigured() {
return (ThucydidesSystemProperty.SAUCELABS_ACCESS_KEY.from(environmentVariables) == null);
}

How Exactly can we configure Sauce Labs after disabling sauce labs.url serenity property.

Really appreciate your help.

Hi Charan,

You can still run your appium mobile test cases on saucelabs by giving saucelabs local host path in appium.hub property as below. I have commented out saucelabs.url but provided that url in appium.hub.

Therefore it will consider driver as Android driver and not RemoteDriver.

saucelabs.test.name = Test-Saucelabs-Android
webdriver.driver = appium
appium.hub = http://SaucelabsUsername:SaucelabsAccessKey@localhost:4445/wd/hub
appium.platformName = Android
appium.platformVersion = 5.1
appium.deviceName = Android Emulator
appium.browserName = Browser
appium.deviceType = tablet
appium.deviceOrientation = portrait
appium.hasTouchScreen= true

saucelabs.url=http://SaucelabsUsername:SaucelabsAccessKey@localhost:4445/wd/hub

saucelabs.access.key=SaucelabsAccessKey
saucelabs.user.id=SaucelabsUsername

With respect to video link in report. The function is in "net.thucydides.core.reports.saucelabs.SaucelabsLinkGenerator"

private boolean saucelabsIsNotConfigured() {
return (ThucydidesSystemProperty.SAUCELABS_URL.from(environmentVariables) == null);
}

Just replace this with

private boolean saucelabsIsNotConfigured() {
return (ThucydidesSystemProperty.SAUCELABS_ACCESS_KEY.from(environmentVariables) == null);
}

You need to update the jar source.

Thanks,
Lovesh Jain
+642108258442

Can this be re-opened? Problem still persists today

Was this page helpful?
0 / 5 - 0 ratings