I am trying to select departure airport from list of airports that are appeared in a search result.
Stored all airports from the search results in QAFWebElement List Variable Iterated through the List of Airport WebElements and Click on the Airport that matches the airport code given my method setup appears to be correct. Not Sure why It is not selecting the airport. check the below method and also attached screenshot.
@QAFTestStep(description = "User enters departure airport {dAirPort}")
public void enterDepartureAirport(String dAirPort) {
QAFExtendedWebDriver objDriver = getDriver();
BookingPage bookingpage = new BookingPage();
bookingpage.getAirPortSearchTextBox().sendKeys(dAirPort);
List<QAFWebElement> depAirportList = objDriver.getElements(By.xpath("//*[@id=\"airport-serach-panel\"]/div/div[2]/div/ul/li/a/span[2]"));
for(QAFWebElement airPort:depAirportList) {
if(airPort.getText().contains(dAirPort)) {
System.out.println(airPort.getText().contains(dAirPort));
System.out.println(airPort.getText());
airPort.click();
}
}
Assert.assertTrue("Script failed to Select Departure Airport",bookingpage.getAirPortSearchTextBox().verifyNotPresent());
}
Lets me know if anyone see an issue with the method