calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

UPDATED for Xcode 7 - Swipe function doesn't work on iOS Simulators < 9.0 #253

Open rpranata opened 10 years ago

rpranata commented 10 years ago

It might be related to this issue (https://github.com/calabash/calabash-ios/issues/230) however I tried it on the normal orientation and it still doesnt work.

Reproduction steps:

  1. Open console with: DEBUG=1 CALABASH_FULL_CONSOLE_OUTPUT=1 calabash-ios console
  2. Then on the console, start the server from the instruments, with: start_test_server_in_background
  3. Make sure that there is a scrollView (or my case collectionView) on the screen. query "collectionView" yields a result with this description
<UICollectionView: 0xdb74200; frame = (0 0; 320 568); opaque = NO; 
autoresize = W+H; gestureRecognizers = <NSArray: 0xd1b86c0>; 
layer = <CALayer: 0xd1e2a30>; contentOffset: {320, 0}> 
collection view layout: 
<MTCardViewFlowLayout: 0xd1ab400>\n          
    Current Page: 1\n          
    Max Page: 7\n
  1. Swipe with this command: swipe "right", {:query => "collectionView"} results in this log:

    Sending UIA command uia.swipeOffset('{:x 160, :y 284}', '{:query "collectionView", :direction :right}') Result {"status"=>"success", "value"=>":nil", "index"=>0}

Which I assume should go to success but nothing happens on the simulator. Everything else works tho, like touch, scroll but not swipe.

I also found this issue on the Apple Developer Forum (https://devforums.apple.com/message/901404#901404), but since I dont know what UIA method the swipe translates to, Im not 100% sure that it is related.


Cheers, Rendy Pranata

rpranata commented 10 years ago

I also tried using UIAutomation's dragInsideWithOptions on my own and it doesnt work on iOS 7.0 simulator. I also raise the same question on https://devforums.apple.com/thread/213903

jmoody commented 10 years ago

Swiping is broken on the simulator. This is an Apple bug.

http://stackoverflow.com/questions/18792965/uiautomations-draginsidewithoptions-has-no-effect-on-ios7-simulator

rpranata commented 10 years ago

Thanks. Radar has been posted.

jmoody commented 10 years ago

@rpranata thank you so very much for filing a radar. every radar counts.

pennypw commented 10 years ago

Hi Jmoody, I saw you already closed this issue, have you already find the resolution? Could you please share it with me? I still struggle with this issue so hard. ; -(

jmoody commented 10 years ago

@pennypw unfortunately, there is no solution. because of a bug in Apple's simulator, swiping does not work.

pennypw commented 10 years ago

@jmoody Thanks so much for your replying. ;-)

jmoody commented 10 years ago

reopened to make this visible.

ebridges commented 10 years ago

I've found that as a workaround this works:

Then /^I swipe to the (left|right|up|down)$/ do |direction|
    scroll("scrollView index:0", direction)
    sleep(STEP_PAUSE) # optional
end 
caioborges commented 10 years ago

@ebridges tks for sharing. Works perfectly.

mgrebenets commented 10 years ago

Any updates on this one? I know the Apple radar is still open and that things work on device, but I do really need to use swipes on iOS 7 simulator.

As I understand there's no workaround for this one as well, right?

ebridges commented 10 years ago

That workaround I mentioned worked for me!

mgrebenets commented 10 years ago

It does work indeed, but only if you have UIScrollView in view hierarchy and that scroll view is the same view you want to swipe on. If there're multiple scroll views, then need to prepare proper query for scroll to "swipe" correctly. And if there are no scroll views at all, then workaround won't work.

Anyway, in apps that I test 99% of the swipes are done on scroll views, so with some adjustments I can swipe-via-scroll until Apple fix their bug.

Thanks.

csun-resilient commented 10 years ago

Hi this fix doesn't quite work for us. Our case may be specific though, we want to swipe the screen to reveal the left hand navigation menu (using AMSlideMenu: https://github.com/SocialObjects-Software/AMSlideMenu). However doing scroll("scrollView index:0", direction) doesn't move the whole screen to reveal the menu, but rather it seems to (or at least appears to) move all the elements on the page left/right, giving a weird look, rather than moving the whole page left/right. This may be an issue with our usage of the navigation menu library of course but I just wanted to highlight that it doesn't work in all cases.

mgrebenets commented 10 years ago

I assume you have more than 1 scroll view in your view hierarchy. One of them sits at the very bottom and has index 0. So when you try to scroll "scrollView index:0" you're scrolling that view.

Try query("scrollView") first to check how many scroll views are there and then figure out which one of them you need to scroll.

Like I said, I just assume things, could be your actual app has 1 scroll view indeed.

mposchen commented 10 years ago

Has anyone tried it with xcode6?

mishkinf commented 10 years ago

@csun-resilient Did you ever find a fix for your issue? I seem to be experiencing much of the same issue as what you stated. It looks as if it is swiping but it doesn't actually swipe. It's like swiping the wrong element or something.

robsteinde commented 10 years ago

Xcode 6 has the same issue.

irb(main):036:0> launcher.actions.swipe(:left, options)
Sending UIA command
uia.swipeOffset('{:x 235, :y 195.75}', '{:offset {:x 235, :y 195.75}, :status_bar_orientation "right", :direction :left}')
Result
{"status"=>"success", "value"=>":nil", "index"=>9}
":nil"

It does a simple touch :-(

krukow commented 9 years ago

not fixed in iOS 8.1

mishkinf commented 9 years ago

How are people doing their automation given this issue with simulators? A lot of the cloud based services out there for mobile testing require simulators to be used. Does calabash provide any sort of workaround for swiping in a simulator? Or are people resorting to creating a debug build that doesn't require swiping altogether just to make the tests work?

houbena commented 9 years ago

Is this swipe issue still persisting or is there already a fix?

jmoody commented 9 years ago

No fix. We have to wait for Apple to fix their UIAutomation API.

houbena commented 9 years ago

Thanks for the quick answer .. Is there any alternative?

mcostanzo1 commented 9 years ago

hi I need to know if there is any alternative to using the scroll .

I'm using iOS 7.1 simulator . Xcode 5.1.1

thank you very much

alexblack commented 9 years ago

Anyone got a work around for iOS 8.x in simulator?

jmoody commented 9 years ago

@alexblack Nope. It is completely broken. We haven't tried Xcode 7/iOS 9.

mcostanzo1 commented 9 years ago

friends! currently I have version 5.1.1 of Xcode and scroll works well on 7.1 iOS iPad simulator. I use this line in my ruby code for example:

scroll "scrollView index: 2", :down

2015-08-06 3:37 GMT-03:00 Joshua Moody notifications@github.com:

@alexblack https://github.com/alexblack Nope. It is completely broken. We haven't tried Xcode 7/iOS 9.

— Reply to this email directly or view it on GitHub https://github.com/calabash/calabash-ios/issues/253#issuecomment-128266382 .

jmoody commented 9 years ago

@mcostanzo1 scroll has always worked.

:8ball:

What doesn't work is UIAutomation dragInsideWithOptions and flickInsideWithOptions which is what swipe uses under the hood.

I am looking for a PR that can swipe-to-delete a table view row programmatically.

mcostanzo1 commented 9 years ago

okay, sorry for my mistake. I thought they were talking about the scroll.

dismiss the previous comment

2015-08-06 12:33 GMT-03:00 Joshua Moody notifications@github.com:

@mcostanzo1 https://github.com/mcostanzo1 scroll has always worked.

[image: :8ball:]

What doesn't work is UIAutomation dragInsideWithOptions and flickInsideWithOptions which is what swipe uses under the hood.

I am looking for a PR that can swipe-to-delete a table view row programmatically.

— Reply to this email directly or view it on GitHub https://github.com/calabash/calabash-ios/issues/253#issuecomment-128411773 .

amast09 commented 9 years ago

@jmoody we are getting flaky failures when using the pan gesture.

Timed out running command uia.panOffset('{:x 722, :y 250.5}', '{:x 196.5, :y 82.5}', '{}')

We get this error randomly once in every 30-40 runs of our test suite. Have people been experiencing drag and drop issues or do you think it is an issue with our usage of the pan function?

Thanks a million for any kind of help you can provide us!

jmoody commented 9 years ago

@amast09 Can you open a new issue re: pan? Please include details about the Xcode version and Calabash version.

https://github.com/calabash/calabash-ios/wiki#reporting-problems

FWIW, I haven't seen problems with pan yet expect that pan no longer works to change iPad keyboard modes.

jmoody commented 9 years ago

UPDATE In Xcode 7's iOS 9 simulators, swiping appears fixed.

Still broken on iOS 8 simulators in Xcode 7.

Calabash

> query = "UITableView descendant UITableViewCell marked:'d'"
=> "UITableView descendant UITableViewCell marked:'d'"
> swipe(:left, {:query => query})

UIAutomation

var target = UIATarget.localTarget();

target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_PORTRAIT);

target.delay(1)

target.frontMostApp().tabBar().buttons()["Scrolling Views"].tap();

target.delay(1)

target.frontMostApp().mainWindow().elements()["scrolling views home"].tableViews()["table"].tapWithOptions({tapOffset:{x:0.25, y:0.15}});

target.delay(1)

var start = {x:0.90, y:0.44}
var end = {x:0.10, y:0.44}
var options = {startOffset:start, endOffset:end, duration:1.0}

target.frontMostApp().mainWindow().elements()["alphabet"].tableViews()["table"].dragInsideWithOptions(options)

image

jmoody commented 9 years ago

Filed a radar: 22869151 Closed as duplicate: 18250952

Report

Xcode 7 iOS 8 simulators UIAutomation dragInsideWithOptions cannot swipe to delete table view cells

Summary:

Since Xcode 6, UIAutomation dragInsideWithOptions has been broken for the swipe gesture on iOS >= 7 Simulators.

This has been widely reported.

In Xcode 7 and Xcode 7.1 betas, dragInsideWithOptions works for iOS >= 9 simulators.

However, dragInsideWithOptions is still broken when targeting iOS < 9 simulators.

Steps to Reproduce:

  1. Install the attached app on an Xcode 7, iOS 8 simulator
  2. Launch the Instruments.app and target the simulator and app from step 1
  3. Run the following JavaScript

var target = UIATarget.localTarget();

target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_PORTRAIT);

target.delay(1)

target.frontMostApp().tabBar().buttons()["Scrolling Views"].tap();

target.delay(1)

target.frontMostApp().mainWindow().elements()["scrolling views home"].tableViews()["table"].tapWithOptions({tapOffset:{x:0.25, y:0.15}});

target.delay(1)

var start = {x:0.90, y:0.44} var end = {x:0.10, y:0.44} var options = {startOffset:start, endOffset:end, duration:1.0}

target.frontMostApp().mainWindow().elements()["alphabet"].tableViews()["table"].dragInsideWithOptions(options)

Expected Results:

Expected to see the 'Delete' button appear (as in the screenshot).

Actual Results:

No gesture is performed or the row is touched.

jjacquet commented 8 years ago

I'm also trying to get under the hood of a UITableViewCell. I need an offset swipe, but nothing seems to be happening. I'm using Xcode 6.4

swipe :left, :query => "UITableViewCellContentView marked: 'test'", :offset => {:x => -100, :y => 0}, :"swipe-delta" => {:horizontal => {:dx=> 200, :dy=> 0} }

When I perform this swipe query in the irb console it doesn't complain, but again nothing happens.

jmoody commented 8 years ago

@jjacquet It will not work on any iOS Simulator < 9.0. It is just broken. Apple is aware of the problem.

jjacquet commented 8 years ago

Thanks for the quick response @jmoody So were all on hold until this is addressed? This is a major roadblock for my team. I do have high hopes for Apples next generation of XCTests in Swift, but in the meantime this is kind of a bummer.

In your new title of this posting "...Swipe function doesn't work on iOS Simulators < 9.0". Are you saying it works on 9.0>?

jmoody commented 8 years ago

@jjacquet

My only advice is to run on devices or iOS 9.* simulators.

In your new title of this posting "...Swipe function doesn't work on iOS Simulators < 9.0". Are you saying it works on 9.0>?

= 9.0. Otherwise, correct.

jjacquet commented 8 years ago

I've updated one of my machines to Xcode 7.0.1 using a 9.0 sim. Now when I put in the swipe method I am getting an undefined method 'error'. Has the syntax changed?

swipe :left, :query => "UILabel marked: 'testAutomationPlaylist'", :offset => {:x => -100, :y => 0}, :"swipe-delta" => {:horizontal => {:dx=> 200, :dy=> 0} } NoMethodError: undefined methodswipe' for nil:NilClass from /Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.16.4/lib/calabash-cucumber/core.rb:359:in swipe' from (irb):2 from /usr/bin/irb:12:in

'`

UPDATE: My server_version is 14.3 and calabash.framework is 16.4 Got to have our developers update that since I maintain CI and not the target. I would guess that's my problem?

jjacquet commented 8 years ago

Hi @jmoody I still can't get the swipe to work. Do think this could be an issue?

WARN: The server version is not compatible with gem version. Please update your server. https://github.com/calabash/calabash-ios/wiki/B1-Updating-your-Calabash-iOS-version gem version: '0.16.4' min server version: '0.16.4' server version: '0.16.2'

jmoody commented 8 years ago

@jjacquet

Now when I put in the swipe method I am getting an undefined method 'error'.

In the console ($ calabash-ios console), you must allow calabash to launch the app before you perform any gestures.

$ bundle exec calabash-ios console
> start_test_server_in_background

The server version is not compatible with gem version

This warning should not have any bearing on swipe. However, you should update the server or use a Gemfile to pin the Calabash gem version to 0.16.2.

mendirattanishant commented 8 years ago

@jmoody

I am still not able to swipe with iOS sim 9.1 and calabash 0.16.4 It says "undefined method `swipe' for nil:NilClass". Has this been resolved?

jmoody commented 8 years ago

@mendirattanishant Where is this happening? In cucumber tests or on the console?

mendirattanishant commented 8 years ago

@jmoody It says on the console

jmoody commented 8 years ago

Please open a new issue. This has nothing to do with the problem described here. In the new issue please:

eearif commented 8 years ago

hey Guys, why are we always lagging behind with calabash ios issues, Swipes, don't work, touch does not work.
accessibility labels don't work. I want us to ramp up the speed and be the first in delivering the best automation framework for ios outbeating appium and others.

eearif commented 8 years ago

@jmoody can you please explain why calabash-ios is slowly becoming outdated and redundant; there was a time when appium was struggling with ios and it was a big pain . Now they are providing much better features and functionalities for both apps and mobile web support . Why is calabash -ios behind, can u please discuss the roadmap and ramp up the speed . Please let us know , as we are highly dependant on calabash-ios .

krukow commented 8 years ago

@eearif - Your comment is plain wrong and not appreciated. Your message is pure FUD. Touches, swipes and all gestures work as do all other features in Calabash. Calabash is neither outdated nor redundant, in-fact Calabash has been more active than appium over the last few months (Appium commits vs Calabash iOS commits although while comparing commits isn't very meaningful it does say something about activity).

Calabash is not lagging behind, but is accelerating: we're close to a major 2.0 release and we're building out new very powerful features as part of that.

I'm not sure what your intent is with these comments, but I consider them malicious and non constructive. If you are experiencing issues please just create a new issue rather than hijacking an existing different issue. Please follow the guide for reporting issues (with examples of good reports): https://github.com/calabash/calabash-ios/wiki#reporting-problems

If you want to test pure browser web-apps use Appium, Calabash is targeting web apps.

If you're looking for a roadmap please see:

https://groups.google.com/d/msg/calabash-ios/KeamyYqVHNQ/mx9TGg-B700J and note that we're working XCUITest support.