Appium-@FindBy无法识别元素-org.openqa.selenium.NoSuchElementException:无法通过此策略定位元素

时间:2020-07-19 11:38:56

标签: java android appium appium-android

在Appium中创建页面工厂设置,脚本无法检测屏幕上的元素。

到目前为止尝试过:

  1. 将AndroidDriver更改为AppiumDriver
  2. 在@AndroidFindBy和@FindBy之间切换

以下是代码的详细信息:

1:初始课程(注意-全局设置具有所有所需的功能和驱动程序启动功能)

<option *ngFor="let option of fromairportlist">{{ option }}</option>

2:这是WelcomePageObjects类的外观

public class TC01_HomePage extends GlobalSetup {

    @Test
    public void HomePages() throws IOException, InterruptedException 
    {   
    AndroidDriver<AndroidElement> driver = GlobalSetup.Capabilities();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    
    WelcomePageObjects welcome = new WelcomePageObjects(driver);
    welcome.verifyWelcomePage();        
    }
}

3:这是元素的uiautomator视图 enter image description here

4:这是Eclipse错误

public class WelcomePageObjects {
    
    AndroidDriver<AndroidElement> driver;
    
    public WelcomePageObjects(AndroidDriver<AndroidElement> driver) 
    {
        this.driver = (AndroidDriver<AndroidElement>)driver;
        PageFactory.initElements(new AppiumFieldDecorator(driver), this);
    }
    
    //Registration Button
    @FindBy(xpath="//android.widget.TextView[@text='Register']")
    private AndroidElement registerBtn;


public void verifyWelcomePage()
    {
        Assert.assertTrue(registerBtn.isDisplayed());
    }   

0 个答案:

没有答案