我是靠谱客的博主 悲凉眼睛,这篇文章主要介绍android element,Android 自动化用 pagefactory 的模式去实现,初始化的 WebElement 类型元素无法转成 RemoteWebElement 或 AndroidE...,现在分享给大家,希望可以做个参考。

public class PGmasterHomePage extends PreservationMaster {

AndroidDriver driver;

public PGmasterHomePage(AndroidDriver driver){

PageFactory.initElements(driver, this);

this.driver=driver;

}

@FindBy(id="com.xx.security:id/xxxx")

public WebElement MasterListTitle;

@FindBy(id="com.xx.security:id/xxxx")

public WebElement MasterListTab;

使用了 PageFactory 的模式去搞 一下 Android 自动化,在初始化 page object 后。控件元素去进行 press() 操作时,会报出如下错误

com.sun.proxy.$Proxy7 cannot be cast to org.openqa.selenium.remote.RemoteWebElement

press 函数的源码如下:

public TouchAction press(WebElement el) {

ActionParameter action = new ActionParameter("press", (RemoteWebElement) el);

parameterBuilder.add(action);

return this;

}

猜想错误的原因是通过 PageFactory.initElements(driver, this);初始化的 WebElement 控件元素无法进行类型转换,因为尝试把 WebElement 的控件元素转成 AndroidElement 类型,

同样会报出 cannot be cast to 的错误。

请各方大神赐教,如何解决用这样的问题,谢谢!

最后

以上就是悲凉眼睛最近收集整理的关于android element,Android 自动化用 pagefactory 的模式去实现,初始化的 WebElement 类型元素无法转成 RemoteWebElement 或 AndroidE...的全部内容,更多相关android内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(116)

评论列表共有 0 条评论

立即
投稿
返回
顶部