org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement

public class Call1 {

public static void main(String[] args) {
		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability("appPackage", "");
		capabilities.setCapability("appActivity", "");
	    AndroidDriver driver = new AndroidDriver(new URL(""), capabilities);
	    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
	}catch(Exception e)



and the error is
Sep 07, 2017 12:12:35 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel’s Law holds true on the remote end
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See for more info.
Sep 07, 2017 12:12:59 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {ELEMENT=1}
Build info: version: ‘unknown’, revision: ‘1969d75’, time: ‘2016-10-18 09:43:45 -0700’
System info: host: ‘Admin-PC’, ip: ‘’, ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_92’
Driver info: driver.version: AndroidDriver
at org.openqa.selenium.remote.RemoteWebDriver.findElement(
at io.appium.java_client.DefaultGenericMobileDriver.findElement(
at io.appium.java_client.AppiumDriver.findElement(
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(
at io.appium.java_client.DefaultGenericMobileDriver.findElementById(
at io.appium.java_client.AppiumDriver.findElementById(
at org.openqa.selenium.By$ById.findElement(
at org.openqa.selenium.remote.RemoteWebDriver.findElement(
at io.appium.java_client.DefaultGenericMobileDriver.findElement(
at io.appium.java_client.AppiumDriver.findElement(
at pack3.Call1.main(
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement
at org.openqa.selenium.remote.RemoteWebDriver.findElement(
… 13 more

The is in this line ------ driver.findElement(“”)).click();

@JithendraKumarCS check -

i have not used any pom or testng xml files

@JithendraKumarCS but you use some version of JAVA-CLIENT that is affected.

So can I use old java client

@JithendraKumarCS better move to latest 5.0.2. which one you have now?

I have 5.0.1 java client

@JithendraKumarCS so try latest 5.0.2 -> not help -> change your selenium versions as suggested in link

As you suggested I changed the selenium version now I am not getting any error but not able to click on the element. I tried element.isDisplayed() method it is showing but not able click on the element.
Can u help on in this?

WebElement ele=driver.findElement(By.className(“android.widget.ImageButton”));
System.out.println(" class is present");
WebElement ele1=driver.findElementById(“”);
System.out.println(“1 --”);;

	    	WebElement ele2=driver.findElementById("");
	    		System.out.println("2 --");;
	    	WebElement ele3=driver.findElementById("");
	    		System.out.println("3 --");;
	    	System.out.println(" class is not present");


class is present
1 –
2 –
3 –

@JithendraKumarCS try to change code like:

        WebElement ele3 = driver.findElement(""));
        new TouchAction((MobileDriver) driver).press(ele3).waitAction(Duration.ofMillis(70)).release().perform();

Sorry for late reply… I tried but getting the below error

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’
System info: host: ‘ADMIN-PC’, ip: ‘’, ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_92’
Driver info:
Capabilities [{, deviceScreenSize=720x1280, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=35b4ac187d63, platform=LINUX, deviceUDID=35b4ac187d63,, desired={,, platformVersion=6.0, automationName=Appium, platformName=Android, deviceName=35b4ac187d63, autoAcceptAlerts=true}, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, javascriptEnabled=true, deviceModel=Redmi 3S, deviceManufacturer=Xiaomi, platformName=LINUX, autoAcceptAlerts=true}]
Session ID: f3a89336-880c-4c2b-b1c9-f5603e812788
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(
at org.openqa.selenium.remote.HttpCommandExecutor.execute(
at io.appium.java_client.remote.AppiumCommandExecutor.execute(
at org.openqa.selenium.remote.RemoteWebDriver.execute(
at io.appium.java_client.DefaultGenericMobileDriver.execute(
at io.appium.java_client.AppiumDriver.execute(
at io.appium.java_client.PerformsTouchActions.performTouchAction(
at io.appium.java_client.TouchAction.perform(
at pack3.Call1.main(

Did you find any resolution to the issue. I am also facing the same issue.

No I tried with so many options, at last even re-install each and every software but not able to resolve the issue. If you get any solution please post the code or fixed patch


I was using following combination:
Appium : 1.6.5
Selenium : selenium-java-3.3.1
Appium Java Client : java-client-5.0.3

I downgraded the Appium client to
Appium Java Client : java-client-5.0.0-BETA6

and the problem was solved.

I am not aware how/where to raise the issue of the version incompatibility issue.

@JithendraKumarCS please try and confirm if it works for you.

Appium : 1.6.5
Selenium : selenium-java-3.3.1
Appium Java Client : java-client-5.0.0-BETA6

I used this combination, same problem…
It is able find the element but not able to click on the dail pad

did really combination of jar file b/w Selenium and appium matters?
Becoze whenever I change the jar file it gives different errors…

Yes, Combination of versions of selenium and appium client matters a lot. I am facing so many issues. Almost new issues with any APP i look to automate. Some links suggest to downgrade even selenium to lower version instead of 3.3.

This is very bad, means how we can judge the compatible jar files b/w Appium and selenium…
From past 2 week I stuck with same problem…
Please if any have the solution on this???

Can anyone provide me the code to click on dail pad in mobile and required jar file versions
finally, screen shot of sdk manager to show what are all installed in it ?

@JithendraKumarCS can you post your code FULL all including imports at and share link?