我们如何通过说@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]");
如果要使用注释访问元素,可以使用页面对象模型。以下是页面对象模型的示例。
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定义为静态