Difference between single scroll and multiple scroll
I have already covered how to implement single scroll at https://mobile-automation-testing.blogspot.com/2021/05/python-appium-how-to-automate-gestures.html
Let us implement multiple scroll for flipkart app
For multiple scroll you have to use TouchAction class as below.
import pytest
from appium import webdriver
from utilities.BaseClass import BaseClass
from time import sleep
from appium.webdriver.common.touch_action import TouchAction
def __init__(self, driver):
self.driver = driver
def test_flipkart_homescreen():
desired_caps = {
'platformName': 'android',
'udid': 'emulator-5556',
'deviceName': 'Pixel 3 API 24',
'platformVersion': '7.0',
'noReset': 'true',
'appPackage': 'com.flipkart.android',
'appActivity': 'com.flipkart.android.activity.HomeFragmentHolderActivity'
}
driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
log = BaseClass().get_logger()
log.info("-------------- Launching Flipkart App --------------")
sleep(5)
log.info("-------------- User is on Flipkart home screen --------------")
touch = TouchAction(driver)
touch.press(x=41, y=1576).move_to(x=44, y=1453).release().perform()
for i in range(4):
touch = TouchAction(driver)
touch.press(x=41, y=1576).move_to(x=44, y=1453).release().perform()
sleep(5)
So the basic difference is multiple scroll can be done multiple times using for loop. such scenarios arises when you want to scroll the items on page till last element is displayed. Sometime "scroll to top" such text is displayed once user reaches to the end of page.
No comments:
Post a Comment