Created
August 15, 2022 01:38
-
-
Save bharathmuddada/e021bb2b98e38658689f0e9768b9ff64 to your computer and use it in GitHub Desktop.
C# Selenium Program to handle web tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SeleniumWebTable { | |
public static void Main(string[] args) | |
{ | |
//var gridurl = new Uri("http://localhost:4444"); | |
new DriverManager().SetUpDriver(new EdgeConfig()); | |
var driver = new EdgeDriver(); | |
driver.Manage().Window.Maximize(); | |
driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/tables"); | |
var rows = driver.FindElements(By.XPath("//table[@id='table1']//tbody/tr")); | |
var columns = driver.FindElements(By.XPath("//table[@id='table1']//tbody/tr[1]/td")); | |
Console.WriteLine("===Rows==="); | |
foreach (var row in rows) { | |
Console.WriteLine(row.Text); | |
} | |
Console.WriteLine("===Columns==="); | |
foreach (var column in columns) | |
{ | |
Console.WriteLine(column.Text); | |
} | |
var FirstRowSecondColumn_text = driver.FindElement(By.XPath("//table[@id='table1']//tbody/tr[1]/td[2]")); | |
Console.WriteLine("The Text from FirstRowSecondColumn : "+FirstRowSecondColumn_text.Text); | |
var FourthRowFifthColumn_text = driver.FindElement(By.XPath("//table[@id='table1']//tbody/tr[4]/td[5]")); | |
Console.WriteLine("The Text from FourthRowFifthColumn_text : " + FourthRowFifthColumn_text.Text); | |
driver.Quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment