Print stock market data table using Selenium Webdriver

0 votes
Is it possible to print data of Stock Market Gainers table using Selenium Webdriver?
May 22, 2019 in Selenium by Ashutosh
1,906 views

1 answer to this question.

0 votes

Hey @Ashutosh, you can use following code snippet to print Stock Market table data using Selenium Webdriver:

public static void main(String[] args) throws InterruptedException {
        
        //set GeckoDriver path for FireFox browser
        System.setProperty("webdriver.gecko.driver","C:\\Users\\Nisha_Parekh\\Downloads\\geckodriver-v0.24.0-win64\\geckodriver.exe");        

        WebDriver driver=new FirefoxDriver();
        driver.manage().window().maximize();
        
        driver.get("https://www.nseindia.com/live_market/dynaContent/live_analysis/top_gainers_losers.htm?cat=G");
        
        Thread.sleep(3000);
        
        //Get Row Count
        int rowCount = driver.findElements(By.tagName("tr")).size();
        
        //Get Column Count
        int colCount = driver.findElements(By.xpath("//tbody//th")).size();
        
        System.out.println("Row count :" + rowCount);
        System.out.println("Col count :" + colCount);
        
        //Print table Data
        for(WebElement tdata:driver.findElements(By.tagName("tr"))){
            System.out.println(tdata.getText());
        }
    }
answered May 23, 2019 by Nisha

Related Questions In Selenium

0 votes
1 answer

How to print all google suggestions for a keyword using Selenium Webdriver?

Hello Cherry, below is the automation script ...READ MORE

answered May 23, 2019 in Selenium by Abha
• 28,140 points
4,858 views
0 votes
1 answer

How can I send some data to a Prompt Alert box using Selenium Webdriver?

Hey Abhishek, you can use sendKeys() method ...READ MORE

answered Jul 3, 2019 in Selenium by Abha
• 28,140 points
8,906 views
0 votes
1 answer

How can I read numeric data from an Excel sheet using Selenium Webdriver?

Hey Jignesh, for reading numeric data from ...READ MORE

answered Jul 17, 2019 in Selenium by Abha
• 28,140 points
7,738 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
12,749 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,622 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
6,697 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,561 views
+1 vote
1 answer

Is it possible to write data into an excel file using Selenium Webdriver?

Hi Simran, if you want to directly ...READ MORE

answered May 8, 2019 in Selenium by Abha
• 28,140 points
6,497 views
0 votes
1 answer

How can I store data into a cookie using Selenium Webdriver?

Hey Abhilasha, we can load a website ...READ MORE

answered Jun 19, 2019 in Selenium by Anvi
• 14,150 points
2,761 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP