0
我正在开发移动Web应用程序自动化。在这里我使用Java,Selenium和Appium。有两个字段我不能自动化。他们是日期和下拉字段。我可以自动化文本字段,复选框和单选按钮。当点击日期字段时,会出现Android默认日期选择器,我无法选择日期。这里是我下面的代码:如何在AndroidElement和WebElement之间切换?
class openBrowser() {
public static WebDriver driver;
public static AppiumDriver<MobileElement> androidDriver;
@Test
public static void launchBrowser(){
desiredCapabalities(...);
androidDriver = new AndroidDriver<MobileElement>(new
URL("http://localhost:4723/wd/hub", desiredCapabilities));
driver = androidDriver;
}
class pickDate() {
MobileElement element;
try{
element = (MobileElement)
androidDriver.findElementByXPath("//android.view.View[@content-desc='28 May
2017']").click();
}catch(Exception e) {
throw e;
}
}
“findElementByXPath()”仅查找网络元素,而不是寻找Android设备/移动元素。请参考日期选择器屏幕截图:Date picker
请向我建议在Web元素和Android/Mobile元素之间切换的任何解决方案。提前致谢。
能否请您粘贴堆栈跟踪? – sjmach
因为,我解决了,dint拿走堆栈跟踪。但它声明'NoSuchElementException'以及驱动程序的细节和功能。 – Bala