Handling Webtable in Selenium



//Handling Web table in Selenium

In following example, we are reading the data from above web table and getting 2nd company price..

public class clsWebtable
{
public IWebDriver dr;
[SetUp]
public void Setup()
{
Console.WriteLine("I am from setup method");
dr = new ChromeDriver(@"C:\Users\username\Desktop"); //Path of your chrome driver

}

 [Test]
 public void Get2ndCompanyDetails()
 {
     Console.WriteLine("started executing Get2ndCompanyDetails at" + DateTime.Now.ToString());
     dr.Navigate().GoToUrl("https://www.moneycontrol.com/stocks/marketinfo/marketcap/bse/index.html");
     IWebElement secondCompany = dr.FindElement(By.XPath("//table[@class='Topfilter_web_tbl_indices__1oyWE undefined']/tbody/tr[2]/td[1]"));
     Console.WriteLine("2nd company name is:" + secondCompany.Text);
     IWebElement secondCompanyPrice = dr.FindElement(By.XPath("//table[@class='Topfilter_web_tbl_indices__1oyWE undefined']/tbody/tr[2]/td[2]")); //This will get 2nd row 2nd column
     Console.WriteLine("2nd company price is:" + secondCompanyPrice.Text);
     Console.WriteLine("Ended executing Get2ndCompanyDetails at" + DateTime.Now.ToString());

 }

}
Tags:
Leave a comment

Your email address will not be published. Required fields are marked *

Subscribe now

Receive weekly newsletter with educational materials, new courses, most popular posts, popular books and much more!

https://bridgejunks.com/ https://crownmakesense.com/ https://brithaniabookjudges.com/ https://hughesroyality.com/ https://rhythmholic.com/ https://bandar89.simnasfikpunhas.com/ https://www.100calshop.co.il/products/thailand/ https://myasociados.com/ https://solyser.com/ http://konfidence.cz/ https://muscadinepdx.com/ https://bandar89.parajesandinos.com.ve/ https://goremekoop.com/ https://oncoswisscenter.com/ https://www.turunclifehotel.com/bandar89/ https://www.houseofproducts.biz/ https://taimoormphotography.com/
BIJI18 BIJI18 BIJI18