appium获取手机端页面元素的操作_05

本文介绍了如何使用Appium来操作手机端页面元素,包括通过AppiumDriver的findElementBy方法、使用AndroidUIAutomator选择器、获取元素坐标并用JS脚本点击,以及处理Webview元素的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.youkuaiyun.com/wyb199026/article/details/50958662

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值