RemoteWebElement can not be cast to

@Shivaji_Ghadge i do not understand you :slight_smile: the code i gave.

1 Like

Thanks it work for me…Thanks a lot…

This combination solved this casting problem for me:

  • java-client-4.1.2.jar

  • selenium-server-standalone-2.53.0.jar

  • appium 1.6.4

Thanks This works for me :slight_smile:

This broke for me all of a sudden with no changes to my dependencies or code (I was actually on vacation over the weekend) for weeks. I believe this started failing Friday 8/18 (We saw some other weird issues in another repo around dependencies, and had to force selenium 3.4.0 to ignore guava and force guava 21.0 as it was trying to use 23.0).

Indeed it appears as though the selenium 3.5.1 release has fouled up some older dependencies that may not have been specific enough, as my 3.3.0 selenium is “upgrading” to 3.5.1:

+--- org.seleniumhq.selenium:selenium-java:3.3.0
|    +--- org.seleniumhq.selenium:selenium-chrome-driver:3.3.0
|    |    \--- org.seleniumhq.selenium:selenium-remote-driver:3.3.0 -> 3.5.1
|    |         +--- org.seleniumhq.selenium:selenium-api:3.5.1
|    |         +--- cglib:cglib-nodep:3.2.4
|    |         +--- org.apache.commons:commons-exec:1.3
|    |         +--- commons-codec:commons-codec:1.10
|    |         +--- commons-logging:commons-logging:1.2
|    |         +--- -> 2.8.1
|    |         +---

Looks like the issue is in the selenium htmlunit dependency that’s grabbing 3.5.1 causing everythingelse to be upgraded

|    \--- org.seleniumhq.selenium:htmlunit-driver:2.24
|         +--- org.seleniumhq.selenium:selenium-support:[2.53.0,4.0.0) -> 3.5.1
|         |    +--- org.seleniumhq.selenium:selenium-api:3.5.1
|         |    +--- org.seleniumhq.selenium:selenium-remote-driver:3.5.1 (*)

To fix this, force seleniumjava to a version, then ignore guava from it (gradle example):

// Selenium 3.5.1 released, caused older selenium issues, so need to force guava to 21.0 and other
// sub-modules where we want them.  thanks htmlunit-driver!

// Uncomment this line, and remove bottom section if things get fixed or you upgrade
// all the way to selenium 3.5.1... but appium doesn't play well with it yet
// compile("org.seleniumhq.selenium:selenium-java:3.3.0")

// All this can go away if htmlunit-driver is fixed for older selenium versions
compile("io.appium:java-client:5.0.0-BETA9") {
    exclude group: 'org.seleniumhq.selenium', module: 'selenium-java'
compile("org.seleniumhq.selenium:selenium-java:3.3.0") {
    exclude group: 'org.seleniumhq.selenium', module: 'htmlunit-driver'
// If you need parts of htmlunit-driver dependencies, uncomment this
// compile("org.seleniumhq.selenium:htmlunit-driver:2.26") {
//     exclude group: 'org.seleniumhq.selenium', module: 'selenium-api'
//     exclude group: 'org.seleniumhq.selenium', module: 'selenium-support'
// }
compile group: 'org.seleniumhq.selenium', name: 'selenium-support', version: "3.3.0"
// Make sure guava is 21.0... others don't play well
compile group: '', name: 'guava', version: '21.0'
// If you need codec stuff from newer commons-codec
compile group: 'commons-codec', name: 'commons-codec', version: '1.10'

Yes selenium 3.5.1 is the culprit, downgrading to 3.4 had successfully able to locate native elements in Android

I faced similar issue with iOS 11.0 and got resolved when i updated java-client to latest i.e., 5.0.4

1 Like
  1. Add commons-lang3-3.1.jar in library
  2. Use java-client-5.0.4.jar instead of previous version.

Your Problem will be solved.

Hi All,

I am still getting same error eventhough I am using latest versions…




public class StartApplication {

	private static AndroidDriver driver;

	public static void main() throws MalformedURLException, InterruptedException {

		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
		capabilities.setCapability("deviceName", "MotoG");
		capabilities.setCapability("platformVersion", "6.0");
		capabilities.setCapability("platformName", "Android");
		 capabilities.setCapability("appPackage", "abc.xys.test");
		capabilities.setCapability("appActivity", "abc.xys.test.HomeActivity");
		driver = new AndroidDriver(new URL(""), capabilities);
		driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS); 


Console O/P ==>
java.lang.NullPointerException at org.openqa.selenium.remote.RemoteWebElement.execute( at

Please Help…

This works after searching again

with reference of this issue

I have downgraded the selenium-jar 3.8.0 to 3.4.0.


Thank you. It solved the same issue for me also