如何创建自动测试滚动列表,直到元素出现在视图中

Stacey丶梦菡
Stacey丶梦菡
订阅者
314
文章
0
粉丝
测试交流1 191字数 243阅读0分48秒阅读模式
摘要我有在python中使用behave framework进行自动化测试的研究案例,我必须在滚动视图android中找到列表中的元素。 对于示例列表:列表A1、列表A2、列表A3、列...

我有在python中使用behave framework进行自动化测试的研究案例,我必须在滚动视图android中找到列表中的元素。
对于示例列表: , 列表A2, 列表A3, 列表B1, 列表B2, ......., . 我一定在列表中找到了一个元素 在滚动页面上使用自动测试,直到该元素在视图中,并且自动滚动将在找到该元素后停止。对于之前滚动手册中的代码自动化示例,我使用以下代码:

@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)

任何人都可以给我python behave中的示例代码来解决这个研究案例。文章源自玩技e族-https://www.playezu.com/180099.html 文章源自玩技e族-https://www.playezu.com/180099.html

 
    • Defandi
      Defandi 9

      使用它:
      context.driver.find_element_by_android_uiautomator(‘new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("List Y27").instance(0));’)

    匿名

    发表评论

    匿名网友
    :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
    确定

    拖动滑块以完成验证