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 in Selenium by Ashutosh
13 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 22 by Nisha

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

I tried to open a new website when a new tab is opened using Selenium Webdriver

Try this code: ArrayList<String> tabs = new ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
577 views
0 votes
1 answer

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,050 points
137 views
0 votes
1 answer
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,130 points
528 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
131 views
0 votes
1 answer
0 votes
1 answer

How to mouse hover on a web element using Selenium WebDriver?

Hello Nitin, to automate mouse hovering over ...READ MORE

answered May 7 in Selenium by Anvi
• 7,160 points
21 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.