public List<Destinations> getItineraryDestinations(HtmlElement itineraryRow, int shipIndex) { logger.info("Returning a list of itinerary destinations for ship index < {} >", shipIndex); List<HtmlElement> tds = itineraryRow.findElements(By.tagName("td")); List<Destinations> destinations = Lists.newArrayList(); HtmlElement td = tds.get(shipIndex); List<HtmlElement> anchors = td.findElements(By.tagName("a")); for (HtmlElement anchor : anchors) { destinations.add(Destinations.valueByHRef(anchor.getAttribute("href"))); } return destinations; }
@Override public CruiseToDestinationPage clickLink(final Destinations destination) throws UrlNotAvailableException { logger.info("Clicking and testing href for link {} Cruises", destination.toString()); Link destinationLink = new Link(findTopDestination(destination)); destinationLink.checkReference(5000); destinationLink.click(); logger.info("Waiting for page CruiseToDestinationPage to be loaded ..."); CruiseToDestinationPage.forDestination(destination); CruiseToDestinationPage c2d = new CruiseToDestinationPage(); logger.info("returning a new page instance -> '{}'", c2d); return c2d; }
private HtmlElement findTopDestination(Destinations destinations) { final By findBy = By.cssSelector( String.format("a[href $='%s-cruises.aspx']", destinations.name().toLowerCase())); return findNavTooltipDiv().findElement(findBy); }