【发布时间】:2019-06-15 23:54:18
【问题描述】:
我面临的问题:无法将返回值转换为 WebElement。 我正在使用 BrowserStack 作为云平台。
我的appium代码:
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();
}
}
控制台输出:
线程“main”中的异常 org.openqa.selenium.WebDriverException:返回值无法转换为 WebElement:{ELEMENT=4EE2A34-EE35-4F14-8EED-A33EEEEEE55} 构建信息:版本:'3.6.0',修订:'6fbf3ec767',时间:'2017-09-27T15:28:36.4Z' 系统信息:主机:'V00XYZ',ip:'100.00.00.100',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'1.8.0_191 ' 驱动信息:driver.version:IOSDriver 在 org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:375) 在 io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62) 在 io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) 在 io.appium.java_client.ios.IOSDriver.findElement(IOSDriver.java:1) 在 org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:473) 在 io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:140) 在 io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1) 在 io.appium.java_client.ios.IOSDriver.findElementByXPath(IOSDriver.java:1) 在 org.openqa.selenium.By$ByXPath.findElement(By.java:361) 在 org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360) 在 io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58) 在 io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) 在 io.appium.java_client.ios.IOSDriver.findElement(IOSDriver.java:1) 在 root.test123.main(test123.java:42) 原因:java.lang.ClassCastException:java.util.HashMap 无法转换为 org.openqa.selenium.WebElement 在 org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:373) ... 13 更多 拿起_JAVA_OPTIONS:-Xmx512M
我的绒球。 xml:
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
注意:我已经尝试了许多在线解决方案..以及以下解决方案。 https://discuss.appium.io/t/org-openqa-selenium-webdriverexception-returned-value-cannot-be-converted-to-webelement/18608
【问题讨论】:
-
尝试使用 AppiumDriver
驱动程序而不是 **AppiumDriver 驱动程序 -
请点击这里的链接stackoverflow.com/questions/46217156/…它有效!
-
请关注链接enter link description here中的答案
标签: java selenium appium appium-ios browserstack