Here is the code snippet I am currently working with:
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.interactions.Actions;
import org.openqa.selenium.support.ui.Select;
public class VirginTrains {
public static void main(String[] args) throws InterruptedException {
String projectPath = System.getProperty("user.dir");
System.out.println("projectPath : " + projectPath);
// THE FOLLOWING CODE IS FOR 1.Journey details
//Opens virgin trains web page
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 code snippet below attempts to select the "Arriving by" option from a drop down:
// click to open the date time picker calendar - 4th Box
Actions actions1 = new Actions(driver);
WebElement departArrive = driver.findElement(By.cssSelector("span[class='dropdownLabel']"));
actions1.doubleClick(departArrive).perform();
driver.findElement(By.cssSelector("span[class='dropdownLabel']")).click();
driver.findElement(By.cssSelector("css=input.Arriving by")).click();
Upon execution, the code should successfully select the "Arriving by" option.