zoukankan      html  css  js  c++  java
  • 花里胡哨的的滑动-定位元素的方法

    转载 滑动的同时找到元素

    https://www.cnblogs.com/psklf/p/5290773.html

     
    UiScrollable scrollView = new UiScrollable(new UiSelector().className("android.widget" +
                            ".ScrollView"));
    
            UiObject itemApps = scrollView.getChildByText(new UiSelector().className("android.widget" +
                    ".TextView"),"Apps");
            itemApps.click();

    new一个 Uiscrollable 的对象,然后用getChild 的方法找到子元素。

    Appium (Python-client)

      def _find_by_scroll(self, item_name):
    
            item = self.driver.find_element_by_android_uiautomator(
                'new UiScrollable(new UiSelector().scrollable(true).instance(0)).getChildByText(new UiSelector().className("android.widget.TextView"), "'
                + item_name + '")')
            item.click()

    区别还是有的,用scrollable(true)找到对象,.instance(0) 再获取子元素

    花里胡哨的的滑动定位  ---》点开连接跳转   转载

    #后面的text查找条件可以用组合查找也可以用 textcontains 关键之查找text,一般查找条件使用text.....因为一般可滑动的区域id和class都是一样的...
    driver.find_element_by_android_uiautomator
        ('new UiScrollable(new UiSelector().resourceId("被滑动区域最后一层的id")).scrollIntoView(new UiSelector().text("我们需要查找的元素text"))')





    #后面的text查找条件可以用组合查找也可以用 textcontains 关键之查找text,一般查找条件使用text.....因为一般可滑动的区域id和class都是一样的...
    driver.find_element_by_android_uiautomator
        ('new UiScrollable(new UiSelector().resourceId("被滑动区域最后一层的id")).scrollIntoView(new UiSelector().text(
    "'+ va + '"
    ))')    红色的部分这样改写库传变量
            # driver.find_element_by_android_uiautomator
            #      ('new UiScrollable(new UiSelector().resourceId("com.southgnss.egstar3:id/listViewTemplateSelectItems")).scrollIntoView(new UiSelector().text("%s"))'%va)
            #
    
            item = self.driver.find_element_by_android_uiautomator(
                'new UiScrollable(new UiSelector().scrollable(true).instance(0)).getChildByText(new UiSelector().className("android.widget.TextView"), "'+ va + '")')
            item.click()
    

      

  • 相关阅读:
    jquery操作select(取值,设置选中)
    POST 服务测试PHP页面
    Web开发者不容错过的20段CSS代码(二)
    Web开发者不容错过的20段CSS代码(一)
    Word排版技巧
    需求分析的故事——如何练就需求分析的火眼金晴?
    如何来书写需求说明书
    Struts配置文件阐释
    做需求要会问为什么和需求场景
    跑通并调试第一个Java Struts程序
  • 原文地址:https://www.cnblogs.com/zhenyu1/p/12716601.html
Copyright © 2011-2022 走看看