GithubHelp home page GithubHelp logo

scroll_up/scroll_down should call touchactions/w3c actions instead of mobile command to make it work for both Android and iOS about appium_capybara HOT 12 OPEN

appium avatar appium commented on June 16, 2024
scroll_up/scroll_down should call touchactions/w3c actions instead of mobile command to make it work for both Android and iOS

from appium_capybara.

Comments (12)

KazuCocoa avatar KazuCocoa commented on June 16, 2024 2

released a new ver which has #50
It wraps TouchAction. thanks, @prashanth-sams !

from appium_capybara.

KazuCocoa avatar KazuCocoa commented on June 16, 2024

Where the swipe_down method?
I could not find it in capybara, too.
https://github.com/teamcapybara/capybara/search?q=swipe_down&type=Code

You can implement the action using below 2 ways.

  1. Use W3C spec action api via Appium client
  2. Use TouchAction API

from appium_capybara.

KazuCocoa avatar KazuCocoa commented on June 16, 2024

you can ask questions in https://discuss.appium.io , too

from appium_capybara.

AlonaPF avatar AlonaPF commented on June 16, 2024

@KazuCocoa I have got similar error when running swipe method on Android emulator (Touch Action class)
error

While debugging i also figured that 'require 'appium_lib' (where the swipe method is in) returns false

I use the following as current_driver
0> Capybara.current_driver => :appium

Also i use the following:
appium_lib (10.3.1)
appium_lib_core (3.2.0)

For iOS - to swipe down i used
Capybara.current_session.driver.browser.execute_script('mobile: scroll', direction: 'down')
It worked, however does not work for Android

from appium_capybara.

KazuCocoa avatar KazuCocoa commented on June 16, 2024

What about Appium::TouchAction.new(Capybara.current_driver.current_session)?
I read the source a bit, and the Capybara.current_driver returns the symbol of driver name managed in the capybara instance.

from appium_capybara.

AlonaPF avatar AlonaPF commented on June 16, 2024

@KazuCocoa i tried - it returns

0> Capybara.current_driver.current_session
=> undefined method `current_session' for :appium:Symbol

If i try Appium::TouchAction.new(Capybara.current_session) then it returns
0> Capybara.current_session => #<Capybara::Session>

And in method:

`0> Appium::TouchAction.new(Capybara.current_session).swipe(start_x: 725, start_y: 1555, end_x: 688, end_y: 236, duration: 600).perform
=> undefined method `touch_actions' for #<Capybara::Session>`

from appium_capybara.

KazuCocoa avatar KazuCocoa commented on June 16, 2024

Maybe, browser method?
It looks returning driver instance.

from appium_capybara.

AlonaPF avatar AlonaPF commented on June 16, 2024

The problem is - appium_capybara does not contain swipe method in lib
Only scroll_up or scroll_down but they are not working on Android with the error:
0> Capybara.current_session.driver.browser.execute_script('mobile: swipe', direction: 'down') => Unknown mobile command "swipe". Only shell,startLogsBroadcast,stopLogsBroadcast,changePermissions,getPermissions,performEditorAction commands are supported.

from appium_capybara.

KazuCocoa avatar KazuCocoa commented on June 16, 2024

ah, I understand.

# new
def scroll_up
browser.execute_script('mobile: scroll', direction: 'up')
end
# new
def scroll_down
browser.execute_script('mobile: scroll', direction: 'down')
end

Thanks.

That is mobile-command, we call, http://appium.io/docs/en/commands/mobile-command/
It can only work xcuitest and espresso driver.

I guess this issue's goal is updating the logic to w3c actions instead of mobile command to work it for both platforms.

from appium_capybara.

AlonaPF avatar AlonaPF commented on June 16, 2024

@KazuCocoa , do you have any idea about workaround for Android because we are not able to use any appium methods for now due to my comment above.
Thanks in advance

from appium_capybara.

KazuCocoa avatar KazuCocoa commented on June 16, 2024

What about W3C actions?
I'm not familiar with Capybara, but if it can call selenium w3c actions, you probably can call it as same.
In general, @driver.action returns the basic action instance. The @driver is Selenium/Appium driver instance. Perhaps, it is browser in Capybara...

Below is an example to scroll which is used in test code in ruby_lib_core.

def w3c_scroll(driver)
  window = driver.window_rect

  action_builder = driver.action
  input = action_builder.pointer_inputs[0]
  action_builder
    .move_to_location(window.width / 2, window.width * 8 / 10)
    .pointer_down(:left)
    .pause(input, 1)
    .move_to_location(window.width / 2, window.width / 10)
    .pause(input, 1)
    .release
    .perform
end

https://github.com/appium/ruby_lib_core/blob/fd2cbde5466a144ce8dccfc6cf330b969bcc8fd3/test/functional/common_w3c_actions.rb#L16
http://appium.io/docs/en/commands/interactions/actions/

from appium_capybara.

prashanth-sams avatar prashanth-sams commented on June 16, 2024

@KazuCocoa fixed in a pull request for this; maybe it is helpful
#50

from appium_capybara.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.