+-+-+ +-+ +-+-+-+-+
|G|O| |4| |H|I|V|E|
+-+-+ +-+ +-+-+-+-+

 --- A GOPHER-LIKE INTERFACE FOR HIVE BLOCKCHAIN ---

🚀 Selenium Automation Practice – Fetching Table Data Without Headers

BY: @cryptomasthan | CREATED: Sept. 28, 2025, 8:23 p.m. | VOTES: 5 | PAYOUT: $0.00 | [ VOTE ]

Hi Everyone,

I just Nowpracticed one of the most commonly asked Selenium interview questions:

👉 “How do you fetch all row data from a web table, excluding the header details?”

I implemented this using Java + Selenium WebDriver + TestNG in Eclipse IDE, and executed the script with Microsoft Edge browser.

📝 Step 1 – Script Preparation

Prepared a Selenium automation script in Java.

Used TestNG framework for execution and validation.

Goal: Fetch all table row data (only values, without headers).

📌 Code Snippet:

**import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.edge.EdgeDriver;
import org.testng.annotations.Test;

public class TableDataHandle {

@Test
public static void tableDataFetching() {

    // Set system property for Edge browser
    System.setProperty("webdriver.edge.driver",
            "D:\\Eclipse-workspace\\SeleniumInterviewPractices\\Drivers\\msedgedriver.exe");

    // Launch Edge browser
    WebDriver driver = new EdgeDriver();

    // Maximize window
    driver.manage().window().maximize();

    // Navigate to target webpage
    driver.get("https://www.w3schools.com/html/html_tables.asp");

    // Locate all rows (excluding header)
    List rowData = driver.findElements(By.xpath("//table[@id='customers']/tbody/tr"));

    // Iterate over rows and fetch all columns
    for (WebElement row : rowData) {
        List cols = row.findElements(By.tagName("td"));

        for (WebElement col : cols) {
            System.out.print(col.getText() + "  ");
        }
        System.out.println();
    }

    // Close browser
    driver.quit();
}

}**

🌐 Step 2 – Browser Launch (Edge)

Script executed successfully with EdgeDriver.

*Microsoft Edge browser" launched and navigated to the target web page containing the table.

📸 Screenshot – Edge Browser Launch

[IMAGE: https://images.ecency.com/DQmaJ2MaJC7MghdBaLeqBUsKZ1yxHYF2vTpkupwv7SjCTHy/1759088823829.jpg]

📋 Step 3 – Console Output

All table data (only values, excluding headers) was printed successfully in the console.

Verified results matched expected values.

📸 Console Output Screenshot

[IMAGE: https://images.ecency.com/DQmctfHPWNk5c4BZWCJfm3MMquiVyVVGpB8EgP3p9vKy7xH/1759089122451.jpg]

✅ Step 4 – Validation with TestNG

Added TestNG assertions to validate successful table data fetch.

Validation Passed – Test case executed correctly.

📸 TestNG Execution Summary Screenshot

[IMAGE: https://images.ecency.com/DQmawCfZwa3KCnrAmtdTbChzNvpsP3w6R8Af23Y4za9qiLC/1759089185527.jpg]

🎯 Final Result

✔ Script executed successfully in Eclipse IDE.
✔ Edge browser launched and navigated correctly.
✔ Table data fetched and printed (headers excluded).
✔ TestNG test case passed.
✔ Captured screenshots for Edge browser, console output, and execution summary.

"💡 Learning Outcome*

This practice helped me:

Understand table handling with Selenium.

Improve my TestNG validation and reporting.

Successfully run automation using Microsoft Edge browser.

Thanks for reading!

TAGS: [ #programming ] [ #technology ] [ #tutorial ] [ #testing ] [ #java ] [ #automation ] [ #selenium ] [ #hive-education ]

Replies

NO REPLIES FOUND.

[ BACK TO TRENDING ] [ BACK TO MENU ]
CMD>