fork download
  1. import java.util.List;
  2.  
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebElement;
  5. import org.openqa.selenium.firefox.FirefoxDriver;
  6.  
  7. class BSEGrains
  8. {
  9.  
  10. public static void main(String[] args) throws Exception
  11. {
  12. FirefoxDriver driver= new FirefoxDriver();
  13. driver.manage().window().maximize();
  14. //open Url
  15. driver.get("http://m...content-available-to-author-only...f.com/index.html");
  16. Thread.sleep(5000);
  17. //Click Graines Link
  18. driver.findElement(By.xpath("/html/body/div[2]/div[8]/div[8]/div[1]/div[4]/div[1]/p/a")).click();
  19. Thread.sleep(5000);
  20. //Locate Table
  21. WebElement mytable = driver.findElement(By.xpath("/html/body/div[1]/div[5]/table/tbody"));
  22. //To Locate rows in table
  23. List<WebElement> rows_table = mytable.findElements(By.tagName("tr"));
  24. //To calculate no of rows In table.
  25. int rows_count = rows_table.size();
  26. System.out.println(rows_count);
  27. //Loop to execute till last row
  28. for(int row = 1; row<rows_count; row++)
  29. {
  30. //To locate columns(cells) of that specific row.
  31. List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName("td"));
  32. // to calculate no of colums in table
  33. int Columns_count = Columns_row.size();
  34. //System.out.println(Columns_count);
  35. for(int Column= 1; Column<Columns_count; Column++)
  36. {
  37. String sColumnValue= driver.findElement(By.xpath("/html/body/div[1]/div[5]/table/tbody/tr["+ row +"]/td[1]")).getText();
  38. String sColumnchange= driver.findElement(By.xpath("/html/body/div[1]/div[5]/table/tbody/tr["+ row +"]/td[5]")).getText();
  39. System.out.println("Top Gainers of BSE " + sColumnValue + " with %change is " + sColumnchange );
  40.  
  41. }
  42.  
  43. }
  44. }
  45. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: package org.openqa.selenium does not exist
import org.openqa.selenium.By;
                          ^
Main.java:4: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebElement;
                          ^
Main.java:5: error: package org.openqa.selenium.firefox does not exist
import org.openqa.selenium.firefox.FirefoxDriver;
                                  ^
Main.java:12: error: cannot find symbol
		FirefoxDriver driver=  new FirefoxDriver();
		^
  symbol:   class FirefoxDriver
  location: class BSEGrains
Main.java:12: error: cannot find symbol
		FirefoxDriver driver=  new FirefoxDriver();
		                           ^
  symbol:   class FirefoxDriver
  location: class BSEGrains
Main.java:18: error: cannot find symbol
		driver.findElement(By.xpath("/html/body/div[2]/div[8]/div[8]/div[1]/div[4]/div[1]/p/a")).click();
		                   ^
  symbol:   variable By
  location: class BSEGrains
Main.java:21: error: cannot find symbol
		WebElement mytable = driver.findElement(By.xpath("/html/body/div[1]/div[5]/table/tbody"));
		^
  symbol:   class WebElement
  location: class BSEGrains
Main.java:21: error: cannot find symbol
		WebElement mytable = driver.findElement(By.xpath("/html/body/div[1]/div[5]/table/tbody"));
		                                        ^
  symbol:   variable By
  location: class BSEGrains
Main.java:23: error: cannot find symbol
		List<WebElement> rows_table = mytable.findElements(By.tagName("tr"));
		     ^
  symbol:   class WebElement
  location: class BSEGrains
Main.java:23: error: cannot find symbol
		List<WebElement> rows_table = mytable.findElements(By.tagName("tr"));
		                                                   ^
  symbol:   variable By
  location: class BSEGrains
Main.java:31: error: cannot find symbol
			   List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName("td"));
			        ^
  symbol:   class WebElement
  location: class BSEGrains
Main.java:31: error: cannot find symbol
			   List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName("td"));
			                                                                   ^
  symbol:   variable By
  location: class BSEGrains
Main.java:37: error: cannot find symbol
				 String sColumnValue= driver.findElement(By.xpath("/html/body/div[1]/div[5]/table/tbody/tr["+ row +"]/td[1]")).getText();
				                                         ^
  symbol:   variable By
  location: class BSEGrains
Main.java:38: error: cannot find symbol
				 String sColumnchange= driver.findElement(By.xpath("/html/body/div[1]/div[5]/table/tbody/tr["+ row +"]/td[5]")).getText();
				                                          ^
  symbol:   variable By
  location: class BSEGrains
14 errors
stdout
Standard output is empty