2017-05-16 34 views

回答

0

我喜欢敲击键盘上的最后一个关键的iOS,而不是藏着掖着

@HowToUseLocators(iOSXCUITAutomation = LocatorGroupStrategy.CHAIN) 
    @iOSXCUITFindBy(className = "XCUIElementTypeKeyboard") 
    @iOSXCUITFindBy(className = "XCUIElementTypeButton") 
    private List<IOSElement> last_iOSKeyboardKey; 

    @HowToUseLocators(iOSXCUITAutomation = LocatorGroupStrategy.CHAIN) 
    @iOSXCUITFindBy(className = "XCUIElementTypeKeyboard") 
    @iOSXCUITFindBy(iOSNsPredicate = "type == 'XCUIElementTypeButton' AND " + 
      "(name CONTAINS[cd] 'Done' OR name CONTAINS[cd] 'return' " + 
      "OR name CONTAINS[cd] 'Next' OR name CONTAINS[cd] 'Go')") 
    private IOSElement last_iOSKeyboardKey_real; 

    public boolean tapLastKeyboardKey_iOS() { 
     System.out.println(" tapLastKeyboardKey_iOS()"); 
     boolean bool = false; 
     setLookTiming(3); 
     try { 
// one way    
//bool = tapElement_XCTest(last_iOSKeyboardKey.get(last_iOSKeyboardKey.size()-1)); 
// slightly faster way 
      bool = tapElement_XCTest(last_iOSKeyboardKey_real); 
     } catch (Exception e) { 
      System.out.println(" tapLastKeyboardKey_iOS(): looks like keyboard closed!"); 
      System.out.println(driver.getPageSource()); 
     } 
     setDefaultTiming(); 
     return bool; 
    } 
0

你可以使用java_client library方法:

driver.findElementByAccessibilityId("Hide keyboard").click(); 

driver.hideKeyboard(HideKeyboardStrategy.TAP_OUTSIDE); 

driver.hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done");