WebDriver中页面滚动(scrolling)

这篇内容主要介绍了如何使用WebDriver进行页面滚动,包括利用focus函数、执行脚本滚动到特定位置、判断滚动条存在以及滚动到元素坐标等操作。针对最新WebDriver代码的变化,还提供了相应的代码更新。
摘要由CSDN通过智能技术生成

这里面主要由链接(http://selenium-tutorial.blogspot.sg/2013/02/scroll-page-webdriver.html)整理过来,主要回答了如何用webdriver来滚动页面,滚上滚下,滚到指定元素以及怎么识别滚动条等。

1.  利用selenium中的focus(locator)函数实现(Link)

@Test
public void testFocus() throws Exception {
	selenium.open("/");
	selenium.windowMaximize();
	selenium.type("q", "selenium wiki");
	selenium.click("btnG");
	//Waiting for an element
	for (int second = 0;; second++) {
		if (second >= 60) fail("timeout");
		try { 
			if (selenium.isElementPresent("link=Selenium Overview - Wiki - Liferay.com")) 
				break; 
			} catch (Exception e) {}
		Thre
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值