diff --git a/example/appium.txt b/example/appium.txt index 6bc7d44..5197557 100644 --- a/example/appium.txt +++ b/example/appium.txt @@ -1,6 +1,6 @@ [caps] platformName = "ios" platformVersion = "15.0" -deviceName ="iPhone Simulator" -automationName = 'XCUITest' +deviceName ="iPhone 11 Pro" +automationName = "XCUITest" app = "./UICatalog.app.zip" diff --git a/example/spec/ios_example_spec.rb b/example/spec/ios_example_spec.rb index ea30e9b..8a4b4b1 100644 --- a/example/spec/ios_example_spec.rb +++ b/example/spec/ios_example_spec.rb @@ -33,5 +33,14 @@ e.send_keys [:shift, :end] expect(e.text).to eq("") + + + Capybara.current_session.driver.appium_driver.back + + sleep 1 + capy_driver.scroll_down + sleep 1 + capy_driver.scroll_up + Capybara.current_session.driver.appium_driver.find_element(:name, 'Text Fields').click end end diff --git a/lib/appium_capybara/driver/appium/driver.rb b/lib/appium_capybara/driver/appium/driver.rb index 3e773d7..1a09ad0 100644 --- a/lib/appium_capybara/driver/appium/driver.rb +++ b/lib/appium_capybara/driver/appium/driver.rb @@ -70,12 +70,30 @@ def accept_modal(type, options = {}, &blk) # new def scroll_up - browser.execute_script('mobile: scroll', direction: 'up') + window = appium_driver.window_rect + + action_builder = appium_driver.action + input = action_builder.pointer_inputs[0] + action_builder + .move_to_location(window.width / 2, window.height / 10) + .pointer_down(:left) + .move_to_location(window.width / 2, window.height * 8 / 10) + .release + .perform end # new def scroll_down - browser.execute_script('mobile: scroll', direction: 'down') + window = appium_driver.window_rect + + action_builder = appium_driver.action + input = action_builder.pointer_inputs[0] + action_builder + .move_to_location(window.width / 2, window.height * 8 / 10) + .pointer_down(:left) + .move_to_location(window.width / 2, window.height / 10) + .release + .perform end # new