appium拖放元素

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

拖放元素的解决方法如下,是开源中国APP增加栏目后,再比较增加栏目名称是否成功的实例:

//移动元素,再比较
		MobileElement layoutView = (MobileElement)driver.findElement(By
            .id("net.oschina.app:id/layout_tab"));
		List support = layoutView.findElements(By
            .className("android.widget.TextView"));
		     MobileElement supportText1=support.get(0);
		     MobileElement supportText4=support.get(3);
		     MobileElement supportTextLast=support.get(support.size()-1);
	        TouchAction touchAction = new TouchAction(driver);
	        touchAction.press(supportText4).perform();
	        try {
	            Thread.sleep(5000);
	        } catch (InterruptedException e) {
	            e.printStackTrace();
	        }
	        touchAction.moveTo(supportText1).release().perform();
	        Thread.sleep(5000);
	        Assert.assertEquals(supportTextLast.getText(),addColumnText);

 

转载于:https://my.oschina.net/u/2315260/blog/824220

你可能感兴趣的:(测试,java,移动开发)