zoukankan      html  css  js  c++  java
  • 遍历frame中的表单:

    遍历frame中的表单:

        public void table1() {
            // 查找frame
            List<WebElement> iframes = driver.findElements(By.tagName("iframe"));
            System.out.println("页面上共找到了" + iframes.size() + "  个iframe对象 !!");
            WebElement frame = iframes.get(0);
            // 进入frame
            driver.switchTo().frame(frame);
            // 共计条数和页数对象
            String sumpage = driver.findElement(By.xpath("html/body/div/div/div/section/div/form/div[2]/li[7]/span"))
                    .getText();
            System.out.println("===========================" + sumpage + "共计多少页------------------------------------");
            String totalCount = (sumpage.substring(sumpage.indexOf("共") + 1, sumpage.lastIndexOf("条")));
            int totalRecord = Integer.parseInt(totalCount.trim());
            int pageSize = 10;
            int totalPageNum = (totalRecord + pageSize - 1) / pageSize;
            System.out.println(
                    "---------------------------------总共有 :" + totalPageNum + "页 !---------------------------------------");
            // 下一页对象;
            WebElement nextPage;
            // WebElement nextPage=
            // driver.findElement(By.xpath("html/body/div/div/div/section/div/form/div[2]/li[6]/a"));
            // System.out.println("==========================已经找到"+nextPage.getText()+"对象!==========================");
            // 查找表单
            /*
             * List<WebElement> tables = driver.findElements(By.tagName("table"));
             * System.out.println("iframes 中共找到了 " + tables.size() + " 个tables !");
             * WebElement table=tables.get(0);
             */
            // 遍历表单
            for (int k = 1; k <= totalPageNum; k++) {
                Log.info("当前是第" + k + " 页!");
                nextPage = driver.findElement(By.xpath("html/body/div/div/div/section/div/form/div[2]/li[6]/a"));
                List<WebElement> tables = driver.findElements(By.tagName("table"));
                System.out.println("iframes 中共找到了 " + tables.size() + " 个tables !");
                WebElement table = tables.get(0);
                List<WebElement> rows = table.findElements(By.tagName("tr"));
                for (WebElement row : rows) {
                    List<WebElement> cols = row.findElements(By.tagName("td"));
                    for (WebElement col : cols) {
                        System.out.print("|");
                        System.out.print(col.getText() + "    |");
                    }
                    System.out.println("");
                }
                nextPage.click();
                // driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
                OpenBrowserInfo.ThreadSleep();
            }
    
            // return null;
        }
    View Code
  • 相关阅读:
    函数中的不定长参数研究 *and**
    copy()与直接=赋值的区别
    python的位运算符
    python的list相关知识
    hadoop报错:hdfs.DFSClient: Exception in createBlockOutputStream
    转载计算机的潜意识的文章:机器学习的入门级经典读物
    完全分布式hadoop2.5.0安装 VMware下虚拟机centos6.4安装1主两从hadoop
    PE结构总导航
    利用函数指针绕过断点
    为什么Fun函数能够执行
  • 原文地址:https://www.cnblogs.com/linbo3168/p/6535325.html
Copyright © 2011-2022 走看看