是否有人在由 Serenity BDD JBehave 框架管理的 PageObject 类中使用了 MobileElement 类?
这是我想与我的 Appium 驱动程序一起使用的 PageObject 类:
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);
}
}
这是我到目前为止所尝试的:
无法通过将 AppiumDriver 显式传递给构造函数来实例化 PageObject,因为框架在内部使用 WebDriverFacade 类。
无法将找到的 WebElement 对象显式转换为 MobileElement 对象(WebElement 由 WebElementFacade 实现时引发的类转换异常)。
任何人都可以帮忙吗?
谢谢