Appium - 无法获取元素

时间:2018-04-24 05:53:51

标签: android selenium appium

在我的原生Android应用程序中,当没有输入firstname时,我会弹出一个弹出窗口。点击'确定'弹出按钮我无法切换回selenium中的先前布局。

public void submit(){
    System.out.println("--->Before submit"+this.webDriver.getPageSource());  //displays source of layout 1
    System.out.println(this.webDriver.currentActivity());
    this.webDriver.findElement(MobileBy.xpath(CreateAccountObjectMap.create_account_submit_button_xpath.getLocator())).click();
}

public void validateNoDataSubmit() throws InterruptedException{
    waitForElement(MobileBy.className(CreateAccountObjectMap.error_box_class.getLocator()));
    System.out.println(this.webDriver.getPageSource());   //Displays new layout2
    WebElement noFirstNameElement = waitForElement(MobileBy.xpath(CreateAccountObjectMap.error_text_xpath.getLocator()));
    waitForElement(MobileBy.xpath(CreateAccountObjectMap.error_box_ok_xpath.getLocator())).click();   //Dismissed error box here
    Thread.sleep(10000);
    System.out.println("Finished waiting for 10 seconds");
    System.out.println("After clicking"+this.webDriver.getPageSource());  //Script stuck here. If I remove this then unable to find element
}

0 个答案:

没有答案