How to get live train status from NTES via Automation.

package trainstatus;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class train_status {


public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "/home/techens/chromedriver/chromedriver");


 WebDriver driver=new ChromeDriver();
 driver.navigate().to("http://enquiry.indianrail.gov.in/ntes/"); //Navigate to NTES
 Thread.sleep(3000);
 driver.findElement(By.cssSelector("#ui-id-16 > button > span")).click(); //Clicks on Enter train number value
 Thread.sleep(3000);
 driver.findElement(By.id("trainInput")).sendKeys(""); //Input train number (eg. 12034, 12033 etc.)
 Thread.sleep(3000);
 driver.findElement(By.id("passThrStn")).click(); //Clicks on Journey/Boarding/Arrival station
 Thread.sleep(3000);
 driver.findElement(By.id("passThrStn")).sendKeys(""); //Input station name (eg. kanpur,New Delhi,Aligarh etc.)
 Thread.sleep(3000);
 driver.findElement(By.id("trainStartDate")).click(); //Clicks on Journey/Boarding/Arrival date
 Thread.sleep(3000);
 driver.findElement(By.cssSelector("#ui-datepicker-div > table > tbody > tr:nth-child(4) > td:nth-child(6) > a")).click(); //Select date from calendar
 Thread.sleep(3000);
 driver.quit(); //Exit Chrome Driver
}

}

Comments

Popular posts from this blog

Book ticket online through IRCTC using Selenium Webdriver.

How to create a New Gmail Account using Selenium Web Driver.

SQL Injection.