0
我想在頁面上的表格滾動。 我讀過this answer。但它不適合我。 This is page were table presented。我如何選擇它與webdriver和滾動到底部?表中的內容是可加載的。我需要這個數來計算表中有多少物品。也許存在一些其他的提示,使其更容易?如何在硒中滾動div?
我想在頁面上的表格滾動。 我讀過this answer。但它不適合我。 This is page were table presented。我如何選擇它與webdriver和滾動到底部?表中的內容是可加載的。我需要這個數來計算表中有多少物品。也許存在一些其他的提示,使其更容易?如何在硒中滾動div?
您可以滾動使用JavaScript:
JavascriptExecutor jsExec = (JavascriptExecutor) driver;
jsExec.executeScript("document.querySelector('#gwt-debug-contentPanel > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > table > tbody > tr:nth-child(1) > td:nth-child(1) > div.GNHGC04CJJ').scrollTop = 500");
但要找出有一個更簡單的方法數:
WebElement number = driver.findElement(By.cssSelector("#gwt-debug-contentPanel > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > table > tbody > tr:nth-child(1) > td:nth-child(1) > div.gwt-HTML"));
String range = number.getText();
那麼高數解析爲整數。