Error 'Returned value cannot be converted to WebElement' with Appium 1.9.0


#1

I’m getting error ‘Returned value cannot be converted to WebElement’:

public void setUp() throws Exception {
    DesiredCapabilities capabilities = getDesiredCapabilities();

    driver = new AppiumDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

When calling:
(MobileElement) driver.findElementByAccessibilityId(id);

It throws an error:
org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement:

I’m using:
Appium 1.9.0,
java.version: ‘1.8.0_152’,
And I have maven dependency defined in my pom file as below:

    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>5.0.4</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>3.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-remote-driver</artifactId>
        <version>3.6.0</version>
    </dependency>

Appium server log:
appium-server-logs.txt (32.8 KB)

Any help would be greatly appreciated.

Thanks,


#2

your client is out of date


#3

Also upgrade selenium-java to 3.14.0


#4

Updated my dependencies and it works now. Thanks a lot!


#6

I have the same problem. Could you please share the pom.xml or dependencies that you are currently using with appium 1.9.0.

Appreciate the help


#7
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>6.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.14.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>3.14.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-remote-driver</artifactId>
        <version>3.14.0</version>
    </dependency>

This worked for me.