【问题标题】:Write Sendkeys commnad in @android for appium在@android 中为appium 编写Sendkeys 命令
【发布时间】:2019-08-26 23:08:56
【问题描述】:

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

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");

【问题讨论】:

    标签: appium sendkeys


    【解决方案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("shr@yopmail.com");
    

    您必须将 AppiumDriver 定义为静态

    【讨论】:

      猜你喜欢
      • 2015-03-07
      • 2020-08-10
      • 1970-01-01
      • 1970-01-01
      • 2014-10-21
      • 2013-12-21
      • 2016-09-05
      • 2019-03-20
      • 1970-01-01
      相关资源
      最近更新 更多