Scroll/Swipe on Android

2,340 views
Skip to first unread message

Mario

unread,
Jan 15, 2014, 12:25:15 PM1/15/14
to appium-...@googlegroups.com
Hi All,

I'm trying to perform a swipe or a scroll on Android emulator (within my hybrid app, of course) and not having any luck.

This is the code I'm executing:

                                JavascriptExecutor js = (JavascriptExecutor) driver;

HashMap<String, Double> object = new HashMap<String, Double>();

object.put("startY", 0.95);

object.put("startX", 0.5);

object.put("endY", 0.05);

object.put("endX", 0.5);

object.put("duration", 1.8);

js.executeScript("mobile: swipe", object);


This is the response I get:

POST /wd/hub/session/16d720bd-133c-403f-9237-ffae14df43e7/execute 500 1ms - 475b
debug: Appium request initiated at /wd/hub/session/16d720bd-133c-403f-9237-ffae14df43e7/execute
debug: Request received with params: {"args":[{"duration":1.8,"startX":0.5,"startY":0.95,"endX":0.5,"endY":0.05}],"script":"mobile: swipe"}
info: Responding to client with error: {"status":9,"value":{"message":"The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource. (Original error: That device doesn't know how to respond to 'mobile: 'swipe--it's probably not using Appium's API)","origValue":"That device doesn't know how to respond to 'mobile: 'swipe--it's probably not using Appium's API"},"sessionId":"16d720bd-133c-403f-9237-ffae14df43e7"}
POST /wd/hub/session/16d720bd-133c-403f-9237-ffae14df43e7/execute 500 0ms - 475b
debug: Appium request initiated at /wd/hub/session/16d720bd-133c-403f-9237-ffae14df43e7/element

I have tried the WebDriver's TouchActions Class with no luck.

I'm running: - Appium 0.13.0
                    - Emulator with Api 17
                    - Both on Mac OS X (10.8.5)
                    - Latest Android SDK tools are available on path.

As always, any help is greatly appreciated.

Thanks in advance,

Mario

Jonathan Lipps

unread,
Jan 15, 2014, 1:19:49 PM1/15/14
to Mario, appium-...@googlegroups.com
many "mobile: " methods don't work in selendroid mode.

--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Mario

unread,
Jan 15, 2014, 1:36:13 PM1/15/14
to appium-...@googlegroups.com
Is there any known way of getting swipe or scroll to work?
I have a hybrid app which has an rss feed which is inside a webview and it's scrollable. For now I haven't found a way of scrolling to the next feed.

Joel Miele

unread,
Jan 15, 2014, 1:47:39 PM1/15/14
to appium-...@googlegroups.com
For Selendroid:

  • flick(WebElement onElement, int xOffset, int yOffset, int speed)
.perform

Mario

unread,
Jan 20, 2014, 11:32:09 AM1/20/14
to appium-...@googlegroups.com
Thanks Joel.

I was missing the .perform() so nothing was happening.. Rookie mistake :(

jwallis

unread,
Jan 24, 2014, 3:19:51 PM1/24/14
to appium-...@googlegroups.com
I've been using android on appium and just got into selendroid, so here's some of my exploratory code in case someone else can use it some day

# cannot click things like Android Settings menu button.  Would have to do by x,y coords I guess?

from android import *; f=Flow(); flow=f
from selenium.webdriver.common.touch_actions import TouchActions

driver =...
driver.page_source
e=driver.find_element_by_link_text('qa1')
ta = TouchActions(driver).flick_element(e, 0, -100, 0)
ta.perform()

e = driver.find_element_by_link_text('qa1')
e.click()

ta=TouchActions(driver).tap_and_hold(300,300)
ta.move(300,500)
ta.release(300,500)
ta.perform()

e = driver.find_element_by_name('chat_textfield')
print e.tag_name
print e.get_attribute('name')
print e.get_attribute('class')
e.send_keys('test msg')
Reply all
Reply to author
Forward
0 new messages