Cannot be cast to org.openqa.selenium.WebElement

I took an error like “Failed to tap on element … (Root cause: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement)”

Is that one related to version? and how to solve this?

1 Like

I suppose you are using Appium 1.9 based on your current provided error message. Katalon Studio does not support Appium 1.9 at the moment, so please use Appium 1.8 instead.

1 Like

Vinh Nguyen said:

I suppose you are using Appium 1.9 based on your current provided error message. Katalon Studio does not support Appium 1.9 at the moment, so please use Appium 1.8 instead.

Thanks for your answer but it didn’t work. Is there another solution you know?

@Vinh Nguyen , @Chris Trevarthen is there any update about this problem?

So please provide your current used test script in this case

Vinh Nguyen said:

So please provide your current used test script in this case

**test script: **
Mobile.startApplication(‘xxxxx’, false)

Mobile.comment(‘yyyyy’)

Mobile.tap(findTestObject(‘XCUIElementTypeStaticText - Login’), 30)

LOG VIEWER

Test Cases/TabsChanges/TabsChanges_Overview FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Failed to tap on element ‘Object Repository/XCUIElementTypeStaticText - Login’** (Root cause: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement)**

at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)

at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.stepFailed(MobileKeywordMain.groovy:40)

at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.runKeyword(MobileKeywordMain.groovy:23)

at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword.tap(TapKeyword.groovy:83)

at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword.execute(TapKeyword.groovy:66)

at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:53)

at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.tap(MobileBuiltInKeywords.groovy:485)

at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords$tap$0.call(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)

at Script1539756270175.run(Script1539756270175.groovy:26)

at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:183)

at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:108)

at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:294)

at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:285)

at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:264)

at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:256)

at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:200)

at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:99)

at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:90)

at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149)

Should be it is related to Xcode version?
Because I am taking “Unable to capture objects Reason: SWTException” when I want to use Spy Mobile. @Vinh Nguyen @Chris Trevarthen

Katalon version: 5.8.3
xcode : 9.2
appium: 1.8.1

the problem was related to appium directory. I don’t know why but in my computer, there are 2 different folder which names are appium . So , if someone had a problem about cast, should check appium path and appium version 1.8.1

Vinh Nguyen said:

I suppose you are using Appium 1.9 based on your current provided error message. Katalon Studio does not support Appium 1.9 at the moment, so please use Appium 1.8 instead.

Thanks, this worked for me when I downgraded from 1.9 to 1.8.1.