Skip to content

Latest commit

 

History

History
55 lines (43 loc) · 2.04 KB

w3c.md

File metadata and controls

55 lines (43 loc) · 2.04 KB

Perform touch actions for W3C module. Generate touch pointer action here and users can use this via driver.action

Documentation

Example

dialect #=> :w3c

# then
el = find_element(:name, 'Pickers')
driver.action.click(el).perform #=> work


# Scroll/Swipe
driver.action
      .move_to_location(500, 500).pointer_down(:left)
      .move_to_location(0, 700)
      .release.perform


# Zoom in
# multiple action chains
f1 = driver.action.add_pointer_input(:touch, 'finger1')
f1.create_pointer_move(duration: 1, x: 200, y: 500,
                   origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f1.create_pointer_down(:left)
f1.create_pause(0.5)
f1.create_pointer_move(duration: 1, x: 200, y: 200,
                   origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f1.create_pointer_up(:left)

f2 = driver.action.add_pointer_input(:touch, 'finger2')
f2.create_pointer_move(duration: 1, x: 200, y: 500,
                   origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f2.create_pointer_down(:left)
f2.create_pause(0.5)
f2.create_pointer_move(duration: 1, x: 200, y: 800,
                   origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f2.create_pointer_up(:left)

driver.perform_actions [f1, f2]

Note

Coordinate points

  • jsonwp
    • Relative action coordinates are counted relatively to the top left point of element's rectangle
  • W3C
    • Relative action coordinates are counted relatively to the center of element's rectangle

Limitations

  • WebDriverAgent support only touch as a pointer type.