Skip to content

Latest commit

 

History

History
114 lines (96 loc) · 6.04 KB

ios_xcuitest.md

File metadata and controls

114 lines (96 loc) · 6.04 KB

XCUITest

find elements

with except for XPath and Predicate

examples

find_element(:class, button_class) # Return a element of XCUIElementTypeButton for XCUITest
  • tag/s is alias of find_element :class, element

  • accessibility_id

find_element(:accessibility_id, element) # Return a element which has accessibilityIdentifier, `element`.
  • button/s(value), button_exact/buttons_exact, text/s(value), text_exact/texts_exact
buttons(value) # Return button elements include `value` as its name attributes.

with Predicate

  • We recommend to use predicate strategy instead of XPath strategy.
    • e.g. find_ele_by_predicate/find_eles_by_predicate, find_ele_by_predicate_include/find_eles_by_predicate_include
  • A helpful cheatsheet for predicate
  • For XCUITest(WebDriverAgent), without 'wd' prefixes are supported.

examples

  • textfield/s(value), find/s, find_exact/finds_exact, find_ele_by_predicate/find_eles_by_predicate and find_ele_by_predicate_include/find_eles_by_predicate_include use predicate strategy in their method.
textfield(value) # Return a XCUIElementTypeSecureTextField or XCUIElementTypeTextField element which has `value` text.
finds_exact(value) # Return any elements include `value` as its name attributes.

with Class Chain

with XPath

examples

xpaths("//some xpaths")

Gesture

Workaround

  • mobile: commands depends on WDA and Apple's framework and the behaviour depends on them.
  • Sometimes issues occur such as "doubleTap isn't tapping #548"
    • workaround for it:
      • with selenium-webdriver >= 3.4.0
        def double_tap(element)
          rect = element.rect
          execute_script 'mobile: doubleTap', x: rect.x + rect.width / 2, y: rect.y + rect.height / 2
        end
      • with selenium-webdriver < 3.4.0
          def double_tap(element)
            size = element.size
            location = element.location
            execute_script 'mobile: doubleTap', x: location.x + size.width / 2, y: location.y + size.height / 2
          end

Other actions

Basically, other actions such as type are compatible with automationName = Appium.

Pasteboard