Search code examples
seleniumgroovyautomated-testsgebbrowserstack

Mobile device gestures with Geb through Browserstack


I am attempting to test mobile browsers with Browserstack and Geb. I am having issues registering swipe actions through Browserstack. I am also using Browserstack's new real devices for testing. I am fairly new to this but from my understanding Geb has built in actions so you do not have to instantiate action commands but instead use the interact class. On the other hand I am under the assumption that Browserstack does not need you to import appium and you do not need it in your project to use touch actions. I would like to know if anyone has successfully used interact and touch actions. I have tried:

def swipe(){
    interact {
        dragAndDropBy(image, 0, -200)
    }
}

The above swipes the method but when I expect it to drop the item is then clicked instead

I have also tried:

def swipe2(){
    interact {
        flick(image,-70,0,2)
    }
}

but receive this error:

    No signature of method: utils.NonEmptyNavigator.flick() is applicable for argument types: (geb.content.TemplateDerivedPageContent, java.lang.Integer, java.lang.Integer, java.lang.Integer) values: [apps.site.pages.MensLandingPage -> image: utils.NonEmptyNavigator, ...]

please let me know if I am going about this in the wrong way, misunderstand something, or if you need more information.


Solution

  • Geb currently only supports methods defined on Actions and not on TouchActions inside of interact {} blocks. I've added an issue for adding support for it to Geb's tracker.

    In the meantime you can fallback to using the TouchActions class directly:

    def actions = new TouchActions(browser.driver)
    actions.flick(image.singleElement(), -70, 0, 2)
    actions.perform()