在@android中编写Sendkeys命令以获取appium

问题描述 投票:1回答:1

我们如何通过说@android在Android中编写SendKeys命令

MobileElement username  = (MobileElement) driver.findElementById("com.devere.dcx:id/editTextemail");
username.sendKeys("[email protected]");

我想把它写成android命令,如下所示:

@ android findElementById("com.devere.dcx:id/editTextemail");
username.sendKeys("[email protected]");
appium sendkeys
1个回答
1
投票

如果要使用注释访问元素,可以使用页面对象模型。以下是页面对象模型的示例。

public class Abcd {
    //you can access element using accessibility, id and xpath

    @AndroidFindBy(accessibility = "your cont-desc")
    private MobileElement textInput;

    @AndroidFindBy(id = "your element's id")
    private MobileElement btn;

    public Abcd(AppiumDriver<MobileElement> driver) {
        PageFactory.initElements(new AppiumFieldDecorator(driver), this);
    }

    public boolean inputEmail(String email) {
        textInput.sendkey(email)
    }
}

现在,您可以在测试课程中完成

Abcd abcd=new Abcd(driver);
abcd.inputEmail("[email protected]");

您必须将AppiumDriver定义为静态

© www.soinside.com 2019 - 2024. All rights reserved.