簡體   English   中英

我試圖使用selenium web驅動程序滾動handson表但無法這樣做

[英]I am trying to scroll handson table using selenium web driver but unable to do so

我的handson表有200多條記錄。 但我只能看到前27條記錄,只能看到25列中的前8列。

以下是我嘗試過的代碼類型。

  1. 代碼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. 代碼2:

     Actions action=new Actions(driver); action.sendKeys(Keys.LEFT).perform(); action.sendKeys(Keys.LEFT).perform(); action.sendKeys(Keys.LEFT).perform(); 
  3. 代碼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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM