Java 如何在Serenity BDD框架中的PageObject类中使用MobileElement?
有人在Serenity BDD JBehave框架管理的PageObject类中使用过MobileElement类吗 下面是我希望与Appium驱动程序一起使用的PageObject类:Java 如何在Serenity BDD框架中的PageObject类中使用MobileElement?,java,appium,jbehave,thucydides,serenity-bdd,Java,Appium,Jbehave,Thucydides,Serenity Bdd,有人在Serenity BDD JBehave框架管理的PageObject类中使用过MobileElement类吗 下面是我希望与Appium驱动程序一起使用的PageObject类: public class Benning extends PageObject { @iOSFindBy(id = "iosThingId") @AndroidFindBy(id = "androidThingId") private MobileElement thing;
public class Benning extends PageObject {
@iOSFindBy(id = "iosThingId")
@AndroidFindBy(id = "androidThingId")
private MobileElement thing;
@iOSFindBy(id = "iosOtherThingId")
@AndroidFindBy(id = "androidOtherThingId")
private MobileElement otherThing;
public void doStuff(){
thing.swipe(SwipeElementDirection.DOWN, 3);
}
}
这是我的工作,有点混乱
public class Benning extends PageObject {
@iOSFindBy(id = "iosThingId")
@AndroidFindBy(id = "androidThingId")
private WebElement thing;
@iOSFindBy(id = "iosOtherThingId")
@AndroidFindBy(id = "androidOtherThingId")
private WebElement otherThing;
private String androidThingId = "androindThingId";
private String iosThingId = "iosThingId";
private String androidOtherThingId = "androidOtherThingId";
private String iosOtherThingId = "iosOtherThingId";
public Benning (WebDriver driver) {
super(driver);
//This allows us to use the @Android and @IosFindBy annotations
PageFactory.initElements(new AppiumFieldDecorator(getDriver()), this);
}
public void doStuff(){
String iosOrAndroid = ((WebDriverFacade) driver).getProxiedDriver().toString();
AppiumDriver<MobileElement> wazz = ((AppiumDriver<MobileElement>) ((WebDriverFacade) getDriver()).getProxiedDriver());
MobileElement mobileElementThing;
if (iosOrAndroid.containsIgnoreCase("Android")){
mobileElementThin = wazz.findElementById(androidThingId);
} else {
mobileElementThing = wazz.findElementById(iosThingId);
}
mobileElementThing.swipe(SwipeElementDirection.DOWN, 3);
}
}
公共类Benning扩展了PageObject{
@iOSFindBy(id=“iosshingid”)
@AndroidIndby(id=“androidThingId”)
私有网页元素的东西;
@iOSFindBy(id=“iosOtherThingId”)
@AndroidFindBy(id=“androidOtherThingId”)
私有网页元素其他东西;
私有字符串androidThingId=“androidThingId”;
私有字符串iosshingid=“iosshingid”;
私有字符串androidOtherThingId=“androidOtherThingId”;
私有字符串iosOtherThingId=“iosOtherThingId”;
公共班宁(网络驱动程序){
超级司机;
//这允许我们使用@Android和@IosFindBy注释
initElements(新的AppiumFieldDecorator(getDriver()),这个);
}
公共空间{
字符串iosOrAndroid=((WebDriverFacade)驱动程序).getProxiedDriver().toString();
AppiumDriver wazz=((AppiumDriver)((WebDriverFacade)getDriver()).getProxiedDriver());
移动元素移动元素;
if(iosOrAndroid.containsIgnoreCase(“Android”)){
mobileElementThin=wazz.findElementById(androidThingId);
}否则{
mobileElementThing=wazz.findElementById(iosshingid);
}
mobileElementThing.swip(SwipeElementDirection.DOWN,3);
}
}
以下是我迄今为止所尝试的:
由于框架在内部使用WebDriverFacade类,因此无法通过显式地将AppiumDriver传递给构造函数来实例化PageObject
无法将找到的WebElement对象显式转换为MobileElement对象(WebElement由WebElementFacade实现时引发的类转换异常)
有人能帮忙吗
谢谢您找到解决方法了吗?您找到解决方法了吗?