日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

[Selenium]Turn Page By Scroll Bar

系統 1863 0

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:

  1. Get the total height, button height, scroll bar height
  2. Calculate total move height, totalMoveHeight = totalHeight - 2*buttonHeight - scrollbarHeight
  3. Calculate page number, pageNum = ?totalMoveHeight/scrollbarHeight
  4. Calculate the last page when it is less then a whole page, lessThenOnePageHeight = totalMoveHeight%scrollbarHeight
  5. 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


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 辽源市| 玛多县| 洪雅县| 洪泽县| 卓尼县| 牙克石市| 汝州市| 肥城市| 临武县| 咸宁市| 合肥市| 乌鲁木齐市| 旬阳县| 沐川县| 莱芜市| 瓮安县| 来安县| 洛川县| 邻水| 岐山县| 壶关县| 宁强县| 灵武市| 盘锦市| 滨州市| 岐山县| 台南市| 浑源县| 三江| 高阳县| 巴彦淖尔市| 长顺县| 苍溪县| 延长县| 汉寿县| 通许县| 万载县| 定安县| 资溪县| 大埔区| 微山县|