Search code examples
javascriptseleniumselendroidbrowserstack

Mobile gestures in Selenium / Browserstack with Node


I'm using Mocha to run javascript-based Selenium tests against a mobile website, through Browserstack. My tests work for the trivial cases (find this element, click on it, expect to then find an element with this text).

However, I've now reached a case where I need to simulate a gesture (right-to-left flick). I've found documentation for the TouchActions class in the Selenium Java API (http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/interactions/touch/TouchActions.html), but I haven't found any matching class or method in the Javascript implementations.

Failing that, I attempted to manually deliver the same gesture by click-and-drag of an element on the right side of the screen:

var btn = driver.findElement(webdriver.By.css('h2+button')); 
driver.actions().
  mouseUp().
  mouseMove(btn).
  mouseDown().
  mouseMove({x: -500, y: 0}).
  mouseUp().
  perform();

Unfortunately, that gets me:

UnknownCommandError: The requested command is currently not yet supported by selendroid.

Does anyone have any other suggestions for delivering this gesture through Selenium in Node/js?


Solution

  • BrowserStack uses:

    • iWebDriver for Android Emulators [Few gestures work]
    • Selendroid for Real Android devices [Gestures don't work]

    When you run your tests on BrowserStack's android platform it should, for now, default to android emulators. Try using emulators for now. I'll update once same support is added for real mobile devices.