Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swipe not act as expected #350

Closed
truebit opened this issue Mar 29, 2016 · 20 comments
Closed

swipe not act as expected #350

truebit opened this issue Mar 29, 2016 · 20 comments

Comments

@truebit
Copy link
Contributor

truebit commented Mar 29, 2016

Description

trying to use element.swipe(UP, duration);, but the undergoing swipe(int startx, int starty, int endx, int endy, int duration) does not work as expected

Environment

  • java client build version or git revision if you use some shapshot: 3.4.0
  • Appium server version or git revision if you use some shapshot: 1.5.0
  • Desktop OS/version used to run Appium if necessary: Mac OSX 10.11
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 5.6.0
  • Mobile platform/version under test: iPhone 9.2.1
  • Real device or emulator/simulator: 6s plus

Details

I was trying to do element.swipe(UP, duration).
According to the debug level logs, after some getLocation and getSize requests , appium called swipe(int, int,int,int,int) as below:

[MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":207,"y":439}},{"action":"wait","options":{"ms":1000}},{"action":"moveTo","options":{"x":207,"y":298}},{"action":...

it was a correct swipe up action. but following logs showed that it interpreted the actions wrong to following commands:

[debug] [iOS] Executing iOS command 'performTouch'
[debug] [UIAuto] Sending command to instruments: target.touch([{"touch":[{"x":207,"y":439}],"time":0.2},{"touch":[{"x":207,"y":439}],"time":1.2},{"touch":[{"x":414,"y":737}],"time":1.4}])
[debug] [Instruments] [INST] 2016-03-29 08:44:34 +0000 Debug: Got new command 18 from instruments: target.touch([{"touch":[{"x":207,"y":439}],"time":0.2},{"touch":[{"x":207,"y":439}],"time":1.2},{"touch":[{"x":414,"y":737}],"time":1.4}])
[debug] [Instruments] [INST] 2016-03-29 08:44:34 +0000 Debug: evaluating target.touch([{"touch":[{"x":207,"y":439}],"time":0.2},{"touch":[{"x":207,"y":439}],"time":1.2},{"touch":[{"x":414,"y":737}],"time":1.4}])
[debug] [Instruments] [INST] 2016-03-29 08:44:34 +0000 Debug: target.touch(__NSCFArray)
[debug] [Instruments] [INST] 2016-03-29 08:44:35 +0000 Debug: point is not within the bounds of the screen
[debug] [UIAuto] Socket data received (70 bytes)
[debug] [UIAuto] Got result from instruments: {"status":17,"value":"point is not within the bounds of the screen"}
[HTTP] <-- POST /wd/hub/session/47695b97-9182-4258-a23b-a0f478210510/touch/perform 500 1763 ms - 131
[debug] [Instruments] [INST] 2016-03-29 08:44:35 +0000 Error: VerboseError: point is not within the bounds of the screen

please notice these commands were not swipe UP, but DOWN. and for the y:737 part, the screen size was only (414,736)

Code To Reproduce Issue [ Good To Have ]

no need

Ecxeption stacktraces

Please create a gist with pasted stacktrace of exception thrown by java.

Link to Appium logs

@truebit truebit changed the title swipe not act as expected mobileElement.swipe not act as expected Mar 29, 2016
@truebit truebit changed the title mobileElement.swipe not act as expected swipe not act as expected Mar 29, 2016
@TikhomirovSergey
Copy link
Contributor

@truebit
Hi.
It is the server side bug which has been reported already.
appium/appium#6292
appium/appium#6299

@truebit
Copy link
Contributor Author

truebit commented Apr 1, 2016

After going through all these bug descriptions and related java-client source code. I think it's not server side bug.
It's the bug from java-client which does not adapt the new swipe logic in appium 1.5.
How to fix: rewrite the methods getEndX and getEndY in io.appium.java_client.SwipeElementDirection class to return relative coordinates of end x and end y

@TikhomirovSergey
Copy link
Contributor

Ok. Now I've got it. I think that some refactoring is needed because the same method is used by Android and iOS now. Android still uses absolute coordinates. It seems that the swiping should be implemented differently.

@go2guy
Copy link

go2guy commented Apr 6, 2016

@TikhomirovSergey is there a workaround for swipe until 4.0.0 is released?

@truebit
Copy link
Contributor Author

truebit commented Apr 7, 2016

@nuggit32 You can override swipe(int startx, int starty, int endx, int endy, int duration) to something like:

new TouchAction(getDriver()).press(startx, starty).waitAction(duration).moveTo(endx - startx, endy - starty).release().perform();

@go2guy
Copy link

go2guy commented Apr 7, 2016

@truebit
I did this but got the same results as the swipe. The problem appears the X press is causing an IOS bar to pop with (Menu, views, select, move, close) options.

    Dimension dimensions = driver.manage().window().getSize();
    Double screenHeightStart = dimensions.getHeight() * 0.5;
    int scrollStart = screenHeightStart.intValue();
    Double screenHeightEnd = dimensions.getHeight() * 0.2;
    int scrollEnd = screenHeightEnd.intValue();
        new TouchAction((IOSDriver<IOSElement>) driver).press(0, scrollStart).waitAction(2000)
            .moveTo(0 - 0, scrollEnd - scrollStart).release().perform();

@go2guy
Copy link

go2guy commented Apr 7, 2016

@truebit
Thanks for your help...The menu bar is related to debuggable app developer options. I lowed the waitAction on the press to 100 and it works. Thanks.

new TouchAction((IOSDriver) driver).press(0, scrollStart).waitAction(100)
.moveTo(0 - 0, scrollEnd - scrollStart).release().perform();

TikhomirovSergey added a commit that referenced this issue Apr 12, 2016
@TikhomirovSergey
Copy link
Contributor

@truebit @nuggit32
The build 4.0.0 is coming soon.
Untill it is not released you can clone master and build snapshot locally and use it for your purposes.
I will keep this issue opened till 4.0.0 is published

@BrantK
Copy link

BrantK commented Apr 18, 2016

@TikhomirovSergey Hello, thanks for all your work on Appium. I need to get around the swipe bug somehow so I cloned master and built a jar, but whenever I try to import I get the error:

"Type parameter 'org.openga.selenium.WebElement' is not within its bound: should extend 'WebElement'."

I compiled in Eclipse. Do you know what I'm doing wrong?

@TikhomirovSergey
Copy link
Contributor

@BrantK
Hi.
It is much better to use IntellijIDEA instead
https://github.com/appium/java-client/blob/master/docs/Note-for-developers.md

@TikhomirovSergey
Copy link
Contributor

Also I can build the SNAPSHOT and attach it to this ticket.

@BrantK
Copy link

BrantK commented Apr 19, 2016

That'd be awesome if you could attach a snapshot! I tried to build with IntelliJ and I'm getting a bunch of these errors.

Error:(224, 12) java: The return type is incompatible with org.openqa.selenium.internal.FindsByLinkText.findElementsByPartialLinkText(String)

@TikhomirovSergey
Copy link
Contributor

TikhomirovSergey commented Apr 19, 2016

@BrantK @truebit @nuggit32
Here is the snapshot. Just unzip it and put it to your maven repository
And don't forget change the version at your pom's to 4.0.0-SNAPSHOT.
4.0.0-SNAPSHOT.zip

@BrantK
Copy link

BrantK commented Apr 19, 2016

Works perfect! Thank you so much, I really appreciate it! Keep up all the good work 👍😄

@TikhomirovSergey
Copy link
Contributor

The fix is published now

@rompic
Copy link
Contributor

rompic commented Jun 7, 2016

@TikhomirovSergey this still doesnt work for me on android.
If I try to swipe a drawer menu with
menu.swipe(SwipeElementDirection.DOWN,2000)
I get:

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][1080,1776]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":13,"value":"Coordinate [x=390.0, y=1893.0] is outside of element rect: [0,0][1080,1776]"}

@SrinivasanTarget
Copy link
Member

@rompic Can you please log this separately along with logs inform of gist

@gitsaquib
Copy link

Swipe up is not working

@dinkar19121991
Copy link

dinkar19121991 commented Oct 13, 2016

@SrinivasanTarget
In Android We can only swipe down the list but if we want to swipe up it didn't work, using driver.swipe()

@SrinivasanTarget
Copy link
Member

@dinkar19121991 Log a new issue with all logs needed.

@appium appium locked and limited conversation to collaborators Oct 23, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants