Appium : Clear a field

后端 未结 26 3171
野趣味
野趣味 2020-12-16 16:03

I have my login screen in app now. Each time the app is launched in screen the mobile number is pre filled with the older text.

I just want to know I have tried:

26条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 16:58

    This method worked for me, although I am trying for a better solution. In the meantime please use this method.

    public void clear(String locatorType, String locator, long... waitSeconds)
    {
    
    WebElement we =  getElementWhenPresent(getByLocator(locatorType, locator), waitSeconds);
    
    String text = we.getText();
    
    int maxChars = text.length();
    
    //we.clear() is not working
    
    for (int i = 0; i < maxChars; i++)
    
    ((AppiumDriver)driver).sendKeyEvent(67);
    
    }
    

提交回复
热议问题