Monday 31 May 2021

Python Appium - Multiple scroll


Difference between single scroll and multiple scroll


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

Feature Posts

Python Appium - Step by step procedure for capturing screenshot

 Why To capture screenshot? It is as important as your logs. If there is any failure for any test scenario, we can provide screenshot for th...