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
65 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 by Nisha

Related Questions In Selenium

0 votes
1 answer
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 in Selenium by Abha
• 19,680 points
42 views
0 votes
1 answer
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
427 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
781 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
420 views
+1 vote
1 answer
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 in Selenium by Anvi
• 11,890 points
37 views