I have study case for doing automation testing using behave framework in python, I must find the element on the list in scroll view android.
For the example list: List A1
, List A2
, List A3
, List B1
, List B2
, ......., List Z100
. I must be finding an element on the list List Y27
using automation testing on the scroll page until this element is in view and automation scroll will be stopped after find the element. For the example code automation in scroll manual like before, I am using this code:
@when('I want to buy again') #This is for condition in test case.
def toMyPurchase(context): #Context
isPresent(context, MobileBy.XPATH, my_purchase_locator.SCROLL_VIEW_XPATH) #This is to find path and allocator element ID scroll view page.
context.driver.swipe(474, 1636, 527, 392, 1000) #This is for scroll coordinate.
time.sleep(0.5) #This is for time interval in scroll.
isPresent(context, MobileBy.XPATH, my_purchase_locator.SCROLL_VIEW_XPATH)
context.driver.swipe(474, 1636, 527, 392, 1000)
time.sleep(0.5)
isPresent(context, MobileBy.XPATH, my_purchase_locator.SCROLL_VIEW_XPATH)
context.driver.swipe(474, 1636, 527, 1445, 1000)
time.sleep(0.5)
Anyone, can give me example code in python-behave to resolve this study case.
Use it :
context.driver.find_element_by_android_uiautomator('new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("List Y27").instance(0));')