On the Virgintrains.co.uk website trying to select a arrival train station
In my Code I am able to select the departure location and in the next field I would like to select a arrival location and then tab to the date.
The issue i am having it send the name of the arrival location but it does not commit it and move to the next field.
I have tried to use a tab key so it goes to next field, i have tried select by visible test,
`import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
public class VirginTrains {
@SuppressWarnings("null")
public static void main(String[] args) throws InterruptedException {
String projectPath = System.getProperty("user.dir");
System.out.println("projectPath : " + projectPath);
//Opens virgintrains webpage
System.setProperty("webdriver.chrome.driver", projectPath + "\\drivers\\chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.virgintrains.co.uk/");
//The following maximise the screen size
driver.manage().window().maximize();
//The following selects the Departure train station
WebElement textBoxDep = driver.findElement(By.name("origin_station"));
textBoxDep.sendKeys("London Euston");
//ADD WAIT STATMENT
//Thread.sleep(10000);
THIS SECTION BELOW IS WHERE I AM HAVING THE ISSUE
// Following selects the Arrival train station
WebElement textBoxArr = driver.findElement(By.name("destination_station"));
textBoxArr.sendKeys(" Manchester Piccadilly");
// WebElement option = null;
//option.click();
//ADD WAIT STATMENT
Thread.sleep(10000);
WebElement webElement = null;
webElement.sendKeys(Keys.TAB);
WebElement webElement2 = null;
webElement2.sendKeys(Keys.TAB);`
I am expecting the code to select the required train station and then move to the date field.
The actual result is that it is populating the field but not selecting the station and moving to the next field.