appium滑动屏幕到某元素

开源中国APP-开源资讯-打开某篇资讯的详情,详情内容比较多,咱们能够滑动屏幕到某元素,实现方法:java

//滑动屏幕,查看详情内容,直接找到【相关推荐】元素为止
		MobileElement commentEle = (new WebDriverWait(driver, 60))
		.until(new ExpectedCondition<MobileElement>() {
			@Override
			public MobileElement apply(WebDriver d) {
				int width = driver.manage().window().getSize().width;
				int height = driver.manage().window().getSize().height;
				driver.swipe(width / 2, height * 9/10, width /2 , height/10, 500);
				System.out.println("scroll=======" + height * 3/ 4 + " " + height /8);
		        
				MobileElement tv_blog_detail_about = driver.findElement(By
						.id("net.oschina.app:id/tv_blog_detail_about"));
				return tv_blog_detail_about;
			}
		});
相关文章
相关标签/搜索