zoukankan      html  css  js  c++  java
  • APPium+java如果找到这个元素则继续执行下面的元素,实现方法

    方法

    import org.openqa.selenium.By;
    import org.openqa.selenium.NoSuchElementException;

    public class Chazhaoyuansu {
        
        /**
         * 如果找到这个元素则继续执行下面的元素,找不则返回失败false,返回布尔值
         * @param by
         * @param waitTimes
         * @return
         */
        public static boolean whetherElementVisable(final By by, int waitTimes) {
            for (int attempt = 0; attempt < waitTimes; attempt++) {  
                try {
                    return true;
                } catch (NoSuchElementException e) {
                    if (attempt == waitTimes - 1) {
                        return false;
                    }
                }
            }
            return false;
        }
        
        
    }

    调用

     //如果有协议弹窗,则点击同意
            if (Chazhaoyuansu.whetherElementVisable(By.id("com.cmcc.p.poc:id/tv_title"), 1)) {
                //点击同意
                androidDriver.findElementById("com.cmcc.p.poc:id/tv_confirm").click();
            }else {
                //点击不同意
                androidDriver.findElementById("com.cmcc.p.poc:id/tv_cancel").click();
            }

  • 相关阅读:
    ptrace
    CentOS 5.4 final下Systemtap的安装
    SystemTap 静态探针安装包
    sysdig
    ORACLE 内部原理
    An introduction to KProbes
    CentOS6.5升级手动安装GCC4.8.2 与 CentOS 6.4 编译安装 gcc 4.8.1
    在Oracle Linux上安装dtrace
    dwarf调试信息格式入门
    MySQL 5.6.20-4 and Oracle Linux DTrace
  • 原文地址:https://www.cnblogs.com/tiansc1/p/15704086.html
Copyright © 2011-2022 走看看