mercredi 4 avril 2018

Drop-down doesn't select the value when visible

When you select the family Room, you get 2 drop downs : 1.Asking number of adults 2.Asking number of child Once you select a number from 2nd dropdown, a 3rd dropdown gets visible. For that i use explicit wait, but still it doesn't get selected don't know why?

Website=https://www.trivago.in/?aDateRange[arr]=2018-06-16&aDateRange[dep]=2018-06-20&aPriceRange[to]=0&aPriceRange[from]=0&iPathId=84738&aGeoCode[lat]=10.850516&aGeoCode[lng]=76.27108&iGeoDistanceItem=0&aCategoryRange=0%2C1%2C2%2C3%2C4%2C5&aOverallLiking=1%2C2%2C3%2C4%2C5&sOrderBy=relevance%20desc&bTopDealsOnly=false&iRoomType=9&aRooms[0][adults]=2&aRooms[0][children][]=1&cpt=8473803&iIncludeAll=0&iViewType=0&bIsSeoPage=false&bIsSitemap=false&

  @Test
  public void familyRoomFeature() throws InterruptedException
  {
      //Selecting Family Room from the dropdown
      driver.findElement(By.xpath(".//*[@id='js-fullscreen-hero']/div/form/div[2]/div/div/ul/li               [3]/button")).click();
      Thread.sleep(7000);
      //Selecting Adult age & there is another dropdown where it asks how many kids a user would have
      Select adultSelect=new Select(driver.findElement(By.xpath(".//*[@id='select-num-adults-1']")));
      Select childSelect=new Select(driver.findElement(By.xpath(".//*[@id='select-num-children-1']")));     
      adultSelect.selectByIndex(2);
      childSelect.selectByIndex(1); 
          //So once you select Adult & child selection, another selection dropdown gets visible
      //I get an error here and it doesn't select the child's age inspite of explicit wait
      WebElement childAge =driver.findElement(By.id("select-ages-children-1-78"));
      WebElement childAgedrop = wait.until(ExpectedConditions.visibilityOf(childAge));
      Select childAgeFromSelect = new Select(childAgedrop);
      childAgeFromSelect.selectByIndex(3);
  }
}

Aucun commentaire:

Enregistrer un commentaire