π Selenium Automation Practice β Fetching Table Data Without Headers
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
π 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<WebElement> rowData = driver.findElements(By.xpath("//table[@id='customers']/tbody/tr"));
// Iterate over rows and fetch all columns
for (WebElement row : rowData) {
List<WebElement> 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
π Step 3 β Console Output
All table data (only
Verified results matched expected values.
πΈ Console Output Screenshot
β Step 4 β Validation with TestNG
Added TestNG assertions to validate successful table data fetch.
Validation Passed β Test case executed correctly.
πΈ TestNG Execution Summary Screenshot
π― 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!
Leave π Selenium Automation Practice β Fetching Table Data Without Headers to:
Read more #programming posts
Best Posts From CryptoMasthan
We have not curated any of cryptomasthan's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From CryptoMasthan
- Crypto Market Crash Today β Liquidation Explained & My HIVE, DOT, ICP Buy Plan
- π Selenium Automation Practice β Fetching Table Data Without Headers
- A Beautiful Sunday at Marina Mall β¨
- β¨ Celebrating the Beauty of Ganesha Festival in Nellore β¨
- β¨ Celebrating the Beauty of Ganesha Festival in Nellore β¨
- πΊπΈ H1B Visa New $100,000 Fee β Only for New Applicants
- π° Why I Like Crypto and Hive β My Simple Journey
- Returning to Hive β My Reintroduction
- Trip on devotion dargah in India
- Visiting nice gifts and articles shope
- Unplanned to the Great Chennai Corporation visit
- CONTEST ENTRY (reflection hunter contest -131)
- Chair shadow reflected the road( shadow contest-285) this is my first post
- zoological Park
- Unexpected visit the great and wonderful architecture temple
- CleanPlanet-2(30-aug-2023)
- Clean planet-1(22-08-2023)|This place is Government park in Chennai one
- Weekend traveling to my home π‘ Town
- Introduction to my self
- Greatness of hive block chain system