appium获取手机端页面元素的操作_05
2017-03-31 16:50
169 查看
appium获取手机端页面元素的操作:
a.AppiumDriver对象的findElementBy方法
b.AppiumDriver对象的driver.findElementByAndroidUIAutomator(方法参数)获取元素
其中方法参数为:newUiSelector().className(\""+className+"\").text(\""+text+"\")
或其他实现实例化UiSelector()的String字符串
c.手机屏幕webElement获取坐标并使用js脚本点击坐标
WebElement a = driver.findElementByClassName("");
intwidth = a.getSize().width;
intx = width/2;
inty = a.getLocation().y;
intheight = a.getSize().height;
for (int i = 0 ; i < 10 ; i ++){
avascriptExecutorjs = (JavascriptExecutor) driver;
Map<String, Serializable> element =new HashMap<String, Serializable>();
element.put("touchCount","1");
element.put("x", x);
element.put("y", y + i*height/10);
js.executeScript("mobile: tap",element);
}
d.遇到手机端元素为webview的控件,参考:
http://blog.csdn.net/wyb199026/article/details/50958662
a.AppiumDriver对象的findElementBy方法
b.AppiumDriver对象的driver.findElementByAndroidUIAutomator(方法参数)获取元素
其中方法参数为:newUiSelector().className(\""+className+"\").text(\""+text+"\")
或其他实现实例化UiSelector()的String字符串
c.手机屏幕webElement获取坐标并使用js脚本点击坐标
WebElement a = driver.findElementByClassName("");
intwidth = a.getSize().width;
intx = width/2;
inty = a.getLocation().y;
intheight = a.getSize().height;
for (int i = 0 ; i < 10 ; i ++){
avascriptExecutorjs = (JavascriptExecutor) driver;
Map<String, Serializable> element =new HashMap<String, Serializable>();
element.put("touchCount","1");
element.put("x", x);
element.put("y", y + i*height/10);
js.executeScript("mobile: tap",element);
}
d.遇到手机端元素为webview的控件,参考:
http://blog.csdn.net/wyb199026/article/details/50958662
相关文章推荐
- Javascript获取页面标签元素操作
- 获取iframe中的内容、查找获取指定元素(关于用c++调用WEBBROWSER控件,使用相关接口操作web页面元素的一些方法)
- Appium 获取h5页面元素需要加调试代码
- 关于appium操作真机打开app之后无法定位页面元素的问题的解决办法
- 在父页面中获取iframe子页面元素进行相应操作
- selenium常用命令之操作页面元素及获取元素内容的事件整理
- 基于HtmlUnit获取页面及复选框元素、单击事件操作
- 页面加载让div元素获取焦点,通过键盘操作焦点切换,安卓电视遥控事件
- Android 真机,微信打开 H5,切换到 webview,能通过 webdriver 方法操作页面元素,然后链接到新的 H5 页面后,无法操作元素,appium 服务器没有收到 response,
- selenium常用命令之操作页面元素及获取元素内容的事件整理
- 子页面获取父页面元素并进行相关的操作
- getBoundingClientRect() 来获取页面元素的位置
- [导入]JavaScript DOM笔记:获取及操作元素
- JavaScript DOM笔记:获取及操作元素
- JavaScript DOM笔记:获取及操作元素
- [导入]silvelight中操作html页面元素
- 关于获取页面元素到补充总结
- 使用PreviousPage来获取前一页页面的元素
- 用 Javascript 获取指定页面元素的位置
- js获取页面元素位置函数