[Selenium]Turn Page By Scroll Bar
Description:
Need to turn page by operating scroll bar and find out the element in the current page.
Previous page will not exist in DOM structure when turning page.
Solution:
- Get the total height, button height, scroll bar height
- Calculate total move height, totalMoveHeight = totalHeight - 2*buttonHeight - scrollbarHeight
- Calculate page number, pageNum = totalMoveHeight/scrollbarHeight
- Calculate the last page when it is less then a whole page, lessThenOnePageHeight = totalMoveHeight%scrollbarHeight
- Turn page according to the page number and lessThenOnePageHeight
Code:
/**************************Report Portal–>ReportProductionFlow.java******************************/
public void seleteTemplate_NotClassifiedFactsheet(String template){
//Scroll the scroll bar page by page
Actions actions = new Actions(page.getDriver());
int totalHeight = page.getDiv_scrollbar_TemplateMappingSetting().getSize().getHeight();
int buttonHeight = page.getButton_ScrollbarDown().getSize().getHeight();
int scrollbarHeight = page.getScrollbar_TemplateMappingSetting().getSize().getHeight();
int totalMoveHeight = totalHeight - buttonHeight - buttonHeight - scrollbarHeight;
int pageNum = totalMoveHeight/scrollbarHeight;
int lessThenOnePageHeight = totalMoveHeight%scrollbarHeight;
if(lessThenOnePageHeight>0){
pageNum+=1;
}
for(int i=0;i<pageNum;i++){
if ((i==(pageNum-1))&&(lessThenOnePageHeight>0)) {
scrollbarHeight=lessThenOnePageHeight;
}
actions.dragAndDropBy(page.getScrollbar_TemplateMappingSetting(), 0, scrollbarHeight).perform();
SeleniumUtil.sleep(1);
List <WebElement> groupList = page.getGroupListInTemplateMapping();
int groupNum = groupList.size();
for(int j=0;j<groupNum;j++){
WebElement groupEl=groupList.get(j);
String groupName = groupEl.getText();
if(groupName.equals("Not Classified")){
System.out.println("Find Group : "+groupName+" in page "+i);
WebElement factsheetTemplateEl=page.getDDL_NotClassifiedFactsheet();
factsheetTemplateEl.click();
page.getLink_Template(template).click();
}
}
}
}
/**************************Report Portal–>ReportProductionFlow.java******************************/
/**************************Report Portal–>ReportProductionPage.java******************************/
public WebElement getDiv_scrollbar_TemplateMappingSetting(){
return SeleniumUtil.waitForElementPresent(driver, By.cssSelector("div#uidialog7.uidialog div.uidialogcontent div#mapEditDlgDiv div.tempmapsetup div.itemsgrid div.rtq-grid div.rtq-grid-sz div.rtq-scrollpanel div.rtq-scrollbar.rtq-scrollbar-y"));
}
public WebElement getButton_ScrollbarDown(){
return SeleniumUtil.waitForElementPresent(driver, By.cssSelector("div#uidialog7.uidialog div.uidialogcontent div#mapEditDlgDiv div.tempmapsetup div.itemsgrid div.rtq-grid div.rtq-grid-sz div.rtq-scrollpanel div.rtq-scrollbar.rtq-scrollbar-y a.rtq-scrollbar-down"));
}
public WebElement getScrollbar_TemplateMappingSetting(){
return SeleniumUtil.waitForElementPresent(driver, By.cssSelector("div#uidialog7.uidialog div.uidialogcontent div#mapEditDlgDiv div.tempmapsetup div.itemsgrid div.rtq-grid div.rtq-grid-sz div.rtq-scrollpanel div.rtq-scrollbar.rtq-scrollbar-y div.rtq-scrollbar-bar"));
}
/**************************Report Portal–>ReportProductionFlow.java******************************/
[Selenium]Turn Page By Scroll Bar的更多相关文章
- Selenium - IWebDriver 控制scroll bar到底部
有时候我们需要控制页面滚动条上的滚动条,但滚动条并非页面上的元素,这个时候就需要借助js是来进行操作.一般用到操作滚动条的会两个场景: 注册时的法律条文需要阅读,判断用户是否阅读的标准是:滚动条是否拉 ...
- 浅析selenium的page object模式
selenium目前比较流行的设计模式就是page object,那么到底什么是page object呢,简单来说,就是把页面作为对象,在使用中传递页面对象,来使用页面对象中相应的成员或者方法,能更好 ...
- VS2010/MFC编程入门之二十六(常用控件:滚动条控件Scroll Bar)
回顾上一节,鸡啄米讲的是组合框控件Combo Box的使用.本节详解滚动条控件Scroll Bar的相关内容. 滚动条控件简介 滚动条大家也很熟悉了,Windows窗口中很多都有滚动条.前面讲的列表框 ...
- (七)对话框,单选框(radiobox),复选框(checkbox),列表框(ListBox),组合框(CComboBox),水平滚动条(Horizontal scroll bar),微调(旋转)spincontrol,列表视图控件CListCtrl,静态控件static
1,模态对话框和非模态对话框 // 模态对话框 void CMainFrame::OnDialogExec() { // TODO: 在此添加命令处理程序代码 // 创建对话框对象 CDialog d ...
- NGUI多行输入框和滚动条结合使用(text list script 和scroll bar script)
一,我们添加一个label,如下图:将label属性设置 二,给label添加一个box collider.然后在add component 添加test list,如下图: 三,添加一个脚本Test ...
- NGUI的滚动条的制作(scroll bar script)
一,我们添加一个sprite,添加一个box collider,然后添加一个scroll bar script,我们来看看scroll bar script的属性 看到background和forgr ...
- VS2010-MFC(常用控件:滚动条控件Scroll Bar)
转自:http://www.jizhuomi.com/software/191.html 滚动条控件简介 滚动条大家也很熟悉了,Windows窗口中很多都有滚动条.前面讲的列表框和组合框设置了相应属性 ...
- Python+Selenium使用Page Object实现页面自动化测试
Page Object模式是Selenium中的一种测试设计模式,主要是将每一个页面设计为一个Class,其中包含页面中需要测试的元素(按钮,输入框,标题 等),这样在Selenium测试页面中可以通 ...
- Selenium关于Page Objects
介绍页面对象设计模式.一个页面对象表示在你测试的web页面用户交互的界面. 使用页面对象模式的有点: 创建可重用的代码可以在多个测试用例中使用 减少重复的代码量 如果用户界面改变,只需要修改一个地方 ...
随机推荐
- 最佳C/C++编辑器 source insight3
C/C++嵌入式代码编辑器source insight3下载地址 http://www.sourceinsight.com/eval.html 注册码:SI3US-361500-17409
- 【传输协议】http协议GET与POST传递数据的最大长度能够达到多少
各种web开发语言中,各个页面之间基本都会进行数据的传递,web开发里面比较常用的数据传递方式有get post,一直以来我都只知道get传递的数据量要比post传递的数据量要少,所以传递大数据量还是 ...
- Git 学习记录一
主要来源参考http://www.runoob.com/git/git-install-setup.html Windows 平台上安装 在 Windows 平台上安装 Git 同样轻松,有个叫做 m ...
- 【转】Bash Shell中命令行选项/参数处理
原文网址:http://www.cnblogs.com/FrankTan/archive/2010/03/01/1634516.html 0.引言 写程序的时候经常要处理命令行参数,本文描述在Bash ...
- Hive之 hive与rdbms对比
对比图 总结: Hive并非为联机事务处理而设计,Hive并不提供实时的查询和基于行级的数据更新操作.Hive是建立在Hadoop之上的数据仓库软件工具,它提供了一系列的工具,帮助用户对大规模的数据进 ...
- LCD RGB 控制技术讲解 — 时钟篇(上)
时序图 下面是LCD RGB 控制的典型时序图 天啊,一下就上这玩意,怎么看??? 其实要解释上面的时序图,我们还需要了解一些LCD的显示过程.所以现在只是有个印象,稍后我们详细讲解. LCD显示流 ...
- emacs之配置yasnippet
~/emacsConfig/auto-complete-yasnippet-setting.el (require 'yasnippet) (setq ac-sources (append '(ac- ...
- Linux学习系列之Nginx调优实战
Nginx配置文件性能微调 全局的配置 user www-data; pid /var/run/nginx.pid; worker_processes auto; worker_rlimit_nofi ...
- Air test 基于屏幕比例实现滑动的方法
# -*- encoding=utf8 -*- __author__ = "chenshanju" __docs__ = "基于iOS类实现滑动" from a ...
- [置顶]
Ubuntu16.04+opencv3.3.0的安装配置说明
系统环境: Linux Ubuntu 16.04 [GCC 5.4.0 20160609] on linux2 之前的教程中我们已经安装了做机器学习需要使用的框架TensorFlow,笔者本科阶段 ...