0

How to scroll the horizontal bar in a grid using selenium. This should be repeated in multiple selections. I have to select the value and click submit. I have to check all the column headers. But, there are 46 columns. Please help. I am unable to move it.

List<WebElement> gridlabellist = driver.findElements(By.xpath(".//*[@id='gview_list']/div[3]/div/table/thead/tr/th"));
List<String> all_gridlabellist=new ArrayList<>();
Thread.sleep(1000);
int gl;
System.out.println(gridlabellist.size());
for(gl=0; gl<gridlabellist.size(); gl++)
{
    String gridlabelname=gridlabellist.get(gl).getText();
    boolean dislabel=gridlabellist.get(gl).isEnabled();
    //System.out.println(labelname);

    if((gridlabelname != null) && (gridlabelname.length()!=0) && dislabel)
    {
        System.out.println("\nGrid Label Names displayed: "  + gridlabelname);

        ((JavascriptExecutor)driver).executeScript("window.scrollBy(2000,0)");  
        System.out.println("\nGrid Label Names displayed: " +gridlabelname);
    }
    all_gridlabellist.add(gridlabellist.get(gl).getText());
} 

grid

2
  • I have tried with boolean dislabel=gridlabellist.get(gl).isEnabled(); also tried earlier with "boolean dislabel=gridlabellist.get(gl).isdisabled();" Commented Oct 19, 2016 at 10:32
  • Please help me! Commented Oct 21, 2016 at 9:43

2 Answers 2

1

its a very old question but still relevant enough to answer with alternative ways, another way to solve this problem is to zoom, zoom to 50-30% or even 10%; this will load all the columns and then read them using xpath.

Sign up to request clarification or add additional context in comments.

1 Comment

Do you have sample code by which we can do this ?
0

Try a different approach & test if it works for you

WebElement scroll = driver.findElement(By.xpath("//blah-blah")); JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript( driver.execute_script("arguments[0].scrollIntoView()", scroll);

1 Comment

thanks nandesh for reply but, I have 30+columns. I have to collect all the column header. As per your reply, I have to collect per page. is there any other way?

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.