I am facing the issue : Returned value cannot be converted to WebElement,
I am using BrowserStack as a cloud platform.
My appium code :
package root;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.ios.IOSDriver;
public class test123 {
public static void main(String[] args) throws MalformedURLException, InterruptedException
{
String userName=“brenda467”;
String accessKey=“adfadfadfadf”;
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("browserstack.user", userName);
caps.setCapability("browserstack.key", accessKey);
caps.setCapability("platform","iOS");
//caps.setCapability("platformName","iOS");
caps.setCapability("deviceName","iPhone 7");
caps.setCapability("os_version","10.3");
caps.setCapability("app","bs://asfasdfasfasdfasfa");
caps.setCapability("browserstack.debug",true);
caps.setCapability("automationName","XCUITest");
//caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "60");
caps.setCapability("noReset", true);
AppiumDriver driver = new IOSDriver(new URL("http://hub.browserstack.com/wd/hub/"), caps);
Thread.sleep(900);
driver.findElement(By.xpath("//XCUIElementTypeOther[@name='LOG IN']")).click();
}
}
Console output :
Exception in thread “main” org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {ELEMENT=4EE2A34-EE35-4F14-8EED-A33EEEEEEE55}
Build info: version: ‘3.6.0’, revision: ‘6fbf3ec767’, time: '2017-09-27T15:28:36.4Z’
System info: host: ‘V00XYZ’, ip: ‘100.00.00.100’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: '1.8.0_191’
Driver info: driver.version: IOSDriver
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:375)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.findElement(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:473)
at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:140)
at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.findElementByXPath(IOSDriver.java:1)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.findElement(IOSDriver.java:1)
at root.test123.main(test123.java:42)
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:373)
… 13 more
Picked up _JAVA_OPTIONS: -Xmx512M
My pom . xml :
io.appium
java-client
7.0.0
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
Note : I have already tried many online solutions… along with the below one.
[https://discuss.appium.io/t/org-openqa-selenium-webdriverexception-returned-value-cannot-be-converted-to-webelement/18608](http://this one )