0

I am trying to fetch data from Handsontable. The table contains 700 data, however when i am locating through the Xpath, At first only 27 data found out of 55 and when i scroll down it changes to 22 out of 40. every time its taking random data. Below I have tried to create a scroll and getColumnData functions.

private void scrollDown() {
    JavascriptExecutor js = (JavascriptExecutor) driver();
    js.executeScript("arguments[0].scrollIntoView({block: 'center'});", rows().get(rows().size()-1));
}


protected LinkedList<WebElement> getColumnWebElement(String columnName)
   {
       LinkedList<WebElement> columnElement = new LinkedList<WebElement>();
       int indexColumn = getLocationOfColumnInHeader(columnName) + 3;
       WebElement headerRow = this.headerRow();
       List<WebElement> rows = this.rows();
       System.out.println(this.rows());
       for (WebElement currentRow : rows)
           if (currentRow != headerRow)
           {
               scrollDown();
               WebElement td = driver.getValidatedElementNoWait(currentRow, By.xpath("./td[" + indexColumn + "]"));
               if (td != null)
               {
                   columnElement.add(td);
               }
           }
       return columnElement;
   }

Is there anyway to read all dynamic changing data based on Column name.

Thanks in Advance!

5
  • data is being dynamically pulled up with java script . you have to simulate the scroll down first till you load all the data then you may proceed with the scrape Commented Nov 18, 2019 at 8:30
  • @Uicorn I can add an answer with a function I use to scroll till the end but it's in python . if you want I can post it for you . Commented Nov 18, 2019 at 8:32
  • @ahmed.soli - in my case if i scroll till end it will display/load last 25 data rest will be hidden or based on scroll. Commented Nov 18, 2019 at 9:10
  • i think it doesn't matter if it's hidden as long as it is still available in the dom, but if it got deleted as the hide mechanism then there is no helping it Commented Nov 18, 2019 at 9:53
  • thats the point Commented Nov 19, 2019 at 13:47

1 Answer 1

0

I used below workaround.

  public void changeTableAttribute() {
      JavascriptExecutor js = (JavascriptExecutor) driver();
      WebElement element = driver().findElement(By.xpath("//hot-table/div[@class='handsontable-container handsontable htColumnHeaders']"));
      js.executeScript("arguments[0].setAttribute('style', 'height:15000px')", element);
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.