0

I need to test functionality of media player. There wouldn't be any problem, but I can't figure out how I can drag and drop slider handler to change current track playing position.

I have tried function change_slider_value_to but it does not work for me.

When I do query "slider" it returns an empty set, when I do query "GFSliderView" it returns:

irb(main):014:0> query "GFSliderView"
[
  [0] {
            "class" => "GFSliderView",
               "id" => nil,
             "rect" => {
          "center_x" => 160,
                 "y" => 73,
             "width" => 176,
                 "x" => 72,
          "center_y" => 81.5,
            "height" => 17
      },
         "frame" => {
               "y" => 9,
           "width" => 176,
               "x" => 72,
          "height" => 17
      },
            "label" => nil,
      "description" => "<GFSliderView: 0x1280db60; frame = (72 9; 176 17); autoresize = W+TM+BM; layer = <CALayer: 0x1280da90>>"
  }
]

Is there any way to do something like calabash-android's drag or drag_coordinates on iOS?

I have tried these commands:

send_uia_command :command => "dragFromToForDuration({startOffset:#{from}, endOffset:#{to}, duration:4});"

(where from is actual position of slider handler and to is from with center_x value increased)

uia('target.mainWindow().sliders()[0].dragToValue(0.5);')

change_slider_value_to "SliderHandle.png", 0.2

map("GFSliderView", :changeslider, 0.2)

(also tried with other values, like 10, 0.8 or 100)

None of them worked - some of them caused crash of an app in simulator, some of them just made console stuck.

I am not very advanced with using Calabash (I am working with it for almost two months) and I do know nothing about apps development and UIA commands so I may have done some stupid mistakes.

kjuri
  • 158
  • 1
  • 10

1 Answers1

0

I finally found a solution. I was just using method dragFromToForDuration in a wrong way.

Now I execute following command:

uia("target.dragFromToForDuration({x:'#{start_x}', y:'#{start_y}'}, {x:'#{end_x}', y:'#{end_y}'}, 2)")

(where start_x and start_y are coordinates of start point and end_x and end_y shows where drag should end). It is working perfectly for me.

I decided to post it here to help people find a solution quickly and not to make such silly mistakes as I did :)

kjuri
  • 158
  • 1
  • 10