Swipe is working for android app but not for android browser

Hi,

I am testing mobile browser website. I want to swipe by coordinates how I have done for apps:

driver.swipe(x1,y1, x1, y2, 400)

Above code is working properly in android apps but when same code I am using in android browser testing then it is showing below error message:

AttributeError: ‘WebDriver’ object has no attribute ‘swipe’.

I have tried few things:

ta = TouchAction(driver)
ta.tap(x=100, y=200).wait(100).move_to(x=100, y=80).wait(100).release()

context.driver.execute_script(“mobile: scroll”, {“direction”: “down”})

action = TouchAction(driver)
action.long_press(element).wait_action(3000).move_to(x=100, y=80).perform().release()

but nothing is working from above tried codes.

actions = ActionChains(driver)
actions.move_to_element(element)
actions.perform()

Above code works for android browser but only for those elements which are loaded. But in my case page is not loaded completely. If I will go to the end of page then other elements will starts to load. So I can go to the end of page by using “move_to_element” code, but after that I want to do manual swipe so that other half of the page will also starts loading.

Can anyone help me for coordinate based swipe work around.

Appium Version : 1.17.1
Android emulator version : 8.0 (Oreo)
chrome version : 83

Thanks

WebDriver doesn’t have implementation for swipe, it was implemented for AndroidDriver but it has been deprecated. Touch actions are executed in the Native context, so it should have worked.

@yashi_r Try scrolling with adb command

driver.execute_script('mobile: shell', {'command': 'input swipe', 'args': [ x1, y1, x1, y2, duration]})

https://appium.readthedocs.io/en/latest/en/writing-running-appium/android/android-shell/

Hi @pr4bh4sh,

Thank you so much. I tried your code and it is working.

Thank you for the help.