Reputation: 45
I'm using Appium for iOS Automation testing and I'm getting this error
Returned value cannot be converted to WebElement //*[@text='Search Results']
Appium Java client version: 6.0.0-BETA5
Downgrading java client is not an option for me as I'm using some methods from the latest beta version.
try {
MobileElement titleView = navigationBar.findElement(By.xpath("//*[@text='" + title + "']"));
return titleView.isDisplayed();
}
UPDATE:
I added selenium in my gradle like this:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'io.appium:java-client:6.0.0-BETA5'
implementation 'org.seleniumhq.selenium:selenium-server:3.9.1'
implementation "com.google.code.gson:gson:2.8.2"
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
compileOnly 'org.projectlombok:lombok:1.16.20'
annotationProcessor 'org.projectlombok:lombok:1.16.20'
testImplementation 'junit:junit:4.12'
}
But when running tests, I still get the error. The build version here is 3.11.0. Is that Selenium? What is the right approach here?
org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: //*[@text='Search Results']
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'USGPSNYCM212943.local', ip: 'fe80:0:0:0:462:ed8d:f2e4:f85d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_152-release'
Driver info: driver.version: unknown
Upvotes: 2
Views: 9826
Reputation: 137
I was using
Appium-windows-1.13.0
java-client-5.0.0-BETA6
I have updated it to
Appium-windows-1.15.1
java-client-6.0.0-BETA4
and it worked
Upvotes: 0
Reputation: 876
In the Desired Capabilities add the following additional Capabilities, it should work then:
capability.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "60");
Upvotes: 0
Reputation: 1
If someone is seeing this now, then WebElement search depends upon the what driver you are using.
If AndroidDriver is used then refer generic type as AndroidDriver driver; driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
If appiumDriver is used then refer generic type as AppiumDriver driver; driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
hope it helps!
Upvotes: 0
Reputation: 21
I was struggling with this issue for a couple of days. I tried all the solutions mentioned on various forums like upgrading or downgrading the appium version etc. Finally, the issue was resolved by adding a simple implicit wait of 5 seconds on the driver object. Give it a try if you are facing this issue.
Upvotes: 0
Reputation: 306
Hi Please use following dependencies :
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>6.0.0-BETA5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.9.1</version>
</dependency>
This should solve your problem, even i faced similar issue when i used different selenium server version.
Upvotes: 6