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
278 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 22, 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 22, 2019 in Selenium by Abha
• 27,720 points
486 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 2, 2019 in Selenium by Abha
• 27,720 points
255 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
• 27,720 points
775 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,510 points
1,514 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,850 points
1,477 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,850 points
1,243 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
• 27,720 points
1,522 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,010 points
358 views