1 package pers.xeon.automate.auxt; 2 3 import org.openqa.selenium.By; 4 import org.openqa.selenium.WebElement; 5 6 /** 7 * @author xeon 8 * @version 创建时间:2016年3月25日 上午10:11:07 9 * 高级操作接口 10 */ 11 public interface AdvanceHandle { 12 13 // 窗口最大化 14 public void maximize(); 15 16 /* 17 * 这个方法是用于切换为原来的窗口,但是前提是一定有弹框出现,并且使用过切换窗口方法 18 */ 19 public void changeLastWindow(); 20 21 /* 22 * 当弹框出现的时候,调用就会切换到对应的窗口 23 */ 24 public void changeWindow(); 25 26 /* 27 * 刷新页面之后继续,等待元素 28 */ 29 public boolean waitElementByRefresh(By locator, int time, int k); 30 31 /* 32 * 刷新页面等待元素 不用指定时间,系统指定固定时间 方法重载 默认刷新页面2次,等待5秒 33 */ 34 public boolean waitElementByRefresh(By locator); 35 36 /* 37 * 最好不用这个方法,但是我还是提供给你 这个方法是处理等待元素方法1 38 */ 39 public boolean waitElementByWait(By locator, int time, boolean b); 40 41 /* 42 * 等待无限时间 不建议使用,如果一直没有加载出来,线程就阻塞 43 */ 44 public boolean waitElementByWait(By locator); 45 46 /* 47 * 等待指定时间 建议使用,我自己写的方法 方法与显性等待是一样的 48 */ 49 public boolean waitElementByWait(By locator, int time); 50 51 /* 52 * 判断元素是否存在 53 */ 54 public boolean isElementExsit(By locator); 55 56 /* 57 * 这个方法是处理元素加载方法2 显性等待指定时间 58 */ 59 public WebElement waitElement(By by, int time); 60 61 /* 62 * 默认等10秒 10秒我比较喜欢所以搞一个单独方法,少写一个条件而已 显性等待10秒之内加载,比较好用,建议使用 63 */ 64 public WebElement waitElement(By by); 65 66 /* 67 * 这个方法是处理元素加载的方法3 68 */ 69 public void waitElementByThread(int ms); 70 71 /* 72 * 这个方法是处理元素加载的方法4 建议不要使用这个,这个是隐形等待,当改变这个时候可能会影响其他元素等待 说白了是全局,注意不要使用 73 */ 74 public void waitElementByInvisible(int second); 75 76 /* 77 * 下拉框操作选择字符串为str 按照值定位 这个需要找到下拉框的value值定位 78 */ 79 public void selectValue(String estr, String str); 80 81 /* 82 * 下拉框操作选择字符串为str 可见文本定位 建议用这个 83 */ 84 public void select(String estr, String str); 85 86 /* 87 * 索引定位 下拉框操作选择字符串Index为index 88 */ 89 public void select(String estr, int index); 90 91 /* 92 * 弹框点击确定 93 */ 94 public void alertAccept(); 95 96 /* 97 * 弹框点击确定 98 */ 99 public void alertDismiss(); 100 101 /* 102 * 得到弹框文本 103 */ 104 public void alertGetText(); 105 106 /* 107 * Frame切换 108 */ 109 public void frame(String FrameName); 110 111 /* 112 * 上传文件,上传图片等 方法可能无效,Driver自带的 113 */ 114 public void UploadBySendKeys(String estr, String strPath); 115 116 /* 117 * 上传文件,上传图片 建议使用这个,100%没得问题 我利用复制粘贴,然后你懂得 118 * 这里面的strPath,我使用的相对路径,相对项目的根路径写的(好处就是可以到处移动,他的参考点事这个项目的根路径) 119 */ 120 public void upload(String estr, String strPath); 121 122 123 }
相关文章: