Guest User

Untitled

a guest
Dec 12th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. package testcases;
  2. import java.util.concurrent.TimeUnit;
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebDriver;
  5. import org.openqa.selenium.chrome.ChromeDriver;
  6.  
  7. public class Nifty_Search {
  8.  
  9. public static void main(String[] args) {
  10.  
  11. System.setProperty("webdriver.chrome.driver", "B:\Automation\software\chromedriver_win32\chromedriver.exe");
  12. WebDriver driver = new ChromeDriver();
  13. driver.navigate().to("https://www.nseindia.com/");
  14. driver.manage().timeouts().pageLoadTimeout(20,TimeUnit.SECONDS);
  15. System.out.println("Normal Market Status :: "+driver.findElement(By.xpath("//span[@id='status1']")).getText().trim());
  16. System.out.println("Nifty 50 Today's Price :: "+driver.findElement(By.xpath("//p[@class='right']//nobr")).getText().trim());
  17. System.out.println("Nifty 50 Today's Price Change :: "+driver.findElement(By.xpath("//nobr/span[@class='green' OR @class='red'][1]")).getText().trim());
  18. System.out.println("Company_Name :: "+driver.findElement(By.xpath("//nobr/span[@class='arrowGreen']")).getText().trim());
  19. System.out.println("Nifty 50 Today's Price change Percentage :: "+driver.findElement(By.xpath("//nobr/span[@class='green' OR @class='red'][2]")).getText().trim());
  20. }
  21. }
  22.  
  23. //nobr/span[@class='green' or @class='red'][1]
Add Comment
Please, Sign In to add comment