![](/img/trans.png)
[英]Scroll table and store data in the list using Selenium web driver
[英]I am trying to scroll handson table using selenium web driver but unable to do so
我的handson表有200多條記錄。 但我只能看到前27條記錄,只能看到25列中的前8列。
以下是我嘗試過的代碼類型。
代碼1:
WebElement invoice=driver.findElement(By.xpath("//*[@id='ht_aeb2df21163d7999']/div[1]/div[1]/div[1]/table/tbody/tr[1]/td[7]/a/i")); int y=invoice.getLocation().y; int x=invoice.getLocation().x; Actions act=new Actions(driver); act.clickAndHold(invoice).dragAndDropBy(invoice,x,y).build().perform(); invoice.click();
代碼2:
Actions action=new Actions(driver); action.sendKeys(Keys.LEFT).perform(); action.sendKeys(Keys.LEFT).perform(); action.sendKeys(Keys.LEFT).perform();
代碼3:
JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("scroll(0, 750)");
我會嘗試使用javascript方法,但要將實際元素作為目標滾動。 scroll
功能以窗口為目標。
例如,我可以通過執行來滾動示例
document.querySelectorAll('.wtHolder')[0].scrollTop = 500
使用開發工具控制台。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.