appium - 在@android 中为appium 编写Sendkeys commnad
问题描述
我们如何通过说在 Android 中编写 SendKeys 命令@android
MobileElement username = (MobileElement) driver.findElementById("com.devere.dcx:id/editTextemail");
username.sendKeys("shr@yopmail.com");
我想把它写成这样的android命令:
@ android findElementById("com.devere.dcx:id/editTextemail");
username.sendKeys("shr@yopmail.com");
解决方案
如果要使用注释访问元素,可以使用页面对象模型。以下是页面对象模型的示例。
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("shr@yopmail.com");
您必须将 AppiumDriver 定义为静态
推荐阅读
- swift - Swift MLDataTable - 如何删除行?
- string - 如何在 Go 中返回 Nil 字符串?
- xml - 通过使用 xslt 进行检查,删除了输出 xml 中没有输入 xml 值的标签
- c# - 像指数这样的xml字符串值变成浮点数
- tensorflow - 如何使用 Tensorflow 模型与 tflite_diff_example_test 进行比较
- html - 为什么页脚中的链接不起作用?
- azure-devops - 是否可以在 VSTS 上为不同的环境(阶段)共享任务?
- .net - EndSave(AutoCAD)是什么(.net vb)的成员?
- c# - 比较输入字符串的格式是否正确
- php - PHP 创建 ECDSA 签名并使用 Golang 进行验证