How to access the grid data using selenium webdriver



  • I have application which uses grid to display the details. using selenium web driver how can I access the data present in the grid.Following is the html code

    <div id="contenttable_TeamManagement_WAR_TeamManagementportlet_teamGrid" height="100%" style="overflow: hidden; position: relative; width: 1225.3px; margin-left: 0px; top: 0px;">
    <div id="contenttable_TeamManagement_WAR_TeamManagementportlet_teamGrid" height="100%" style="overflow: hidden; position: relative; width: 1225.3px; margin-left: 0px; top: 0px;">
    <div id="row0_TeamManagement_WAR_TeamManagementportlet_teamGrid" style="position: relative; height: 28px;" role="row">
    <div id="row1_TeamManagement_WAR_TeamManagementportlet_teamGrid" style="position: relative; height: 28px;" role="row">
    <div id="row2_TeamManagement_WAR_TeamManagementportlet_teamGrid" style="position: relative; height: 28px;" role="row">
    <div id="row3_TeamManagement_WAR_TeamManagementportlet_teamGrid" style="position: relative; height: 28px;" role="row">
    <div id="row4_TeamManagement_WAR_TeamManagementportlet_teamGrid" style="position: relative; height: 25px;" role="row">
    <div id="row5_TeamManagement_WAR_TeamManagementportlet_teamGrid" style="position: relative; height: 25px;" role="row">
    <div id="row6_TeamManagement_WAR_TeamManagementportlet_teamGrid" style="position: relative; height: 25px;" role="row">
    <div id="row7_TeamManagement_WAR_TeamManagementportlet_teamGrid" style="position: relative; height: 25px;" role="row">
    <div id="row8_TeamManagement_WAR_TeamManagementportlet_teamGrid" style="position: relative; height: 25px;" role="row">
    <div id="row9_TeamManagement_WAR_TeamManagementportlet_teamGrid" style="position: relative; height: 25px;" role="row">
    </div>
    

    My code:

    WebDriver driver= new FirefoxDriver(); 
    driver.get(Configuration.HelpGuideHomePage.baseURL);
    AppFunctions.authorizedUserLogin(driver, TestData.sEmailAddress, TestData.sPassword); 
    Thread.sleep(3000); 
    AppFunctions.clickTeam(driver); 
    Thread.sleep(3000); //click on check boxes WebElement  
    element=driver.findElement(By.xpath("//div[@class='jqx-checkbox-default jqx-fill-state-normal jqx-rc-all']")); 
    element.click(); 
    


  • To get access to the text of an element you use:

    WebElement element = driver.findElement(By.id("row0_TeamManagement_WAR_TeamManagementportlet_teamGrid"));
    String elementText = element.getText();
    System.out.println(elementText);
    

Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2