0

Here is my existing code:

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();

In the following code I would like to select Arriving by in the 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();

Once the code runs it should select Arriving by

Dpeif
  • 532
  • 1
  • 6
  • 18
  • is this a question ? – G-Cyrillus Apr 12 '19 at 21:32
  • Sorry Yes it is - I am trying to select a value from a drop down but it is not selecting in my script. – Sarabjit Bhamber Apr 12 '19 at 21:36
  • can you clarify this in the question, so every one understand what you tried to do and what is going wrong ;) . Welcome here any way. -*edit*- what is the CSS tag about here ? – G-Cyrillus Apr 12 '19 at 21:41
  • on the website I am testing, there is a field that is a drop down - it has 2 values, From the drop down I would like to select a value from the drop down. When i run the code it displays the drop down but it does not select the Arriving by field. – Sarabjit Bhamber Apr 12 '19 at 21:49

1 Answers1

0

I can see it, you want:

[data-value="Arrive Before"]

Next time just inspect in your elements panel and choose an attribute to select it by.

pguardiario
  • 53,827
  • 19
  • 119
  • 159