解決Appium無元素可選的如何定位(java篇)


1、首先我們看看要定位的東西,我要定位的就是折讓率上圖自己看

寫代碼:
 
AndroidElement element = driver.findElementByAndroidUIAutomator("new UiSelector().className(\"android.widget.LinearLayout\")");//先獲取到該元素
int b = 9;//要滑動幾次才能找到該值,自己掂量
while(b>0){
Thread.sleep(2000);
int x = element.getSize().width;//元素的寬1080
int y = element.getLocation().getY();//元素起始點y
int h =element.getSize().height;//元素的高
driver.swipe(x/2, y+h/10*4, x/2, y+h/10*3, 300);//根據坐標點來滑動
b--;
}
Thread.sleep(2000);
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.dsf.app:id/img_select\")").click();//點擊勾

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM