Keys.ARROW_DOWN does not select an item in the 'Select Box'?



  • I have a select box which has 3 values in the drop-down. When I click on the select box and then further use click() on the value item , it works fine. but when I use Keys.ARROW_DOWN its displays the select values but does not click/select the item in drop down. Also I don't want to use 'Select' class for it. driver.findElement(By.xpath(".//[@id='ctl04_Pane2_AttributeDefinitionCategoryTest']/td[2]//td[2]")).click(); Thread.sleep(2000); driver.findElement(By.xpath(".//[@id='ctl04_Pane2_AttributeDefinitionCategoryTest']/td[2]/div/select")).sendKeys(Keys.ARROW_DOWN); Also if the 'Id' of the select box changes dynamically, then should we use the webdriver 'Select' class for it?



  • You could use driver.findElement(By.xpath(".//[@id='ctl04_Pane2_AttributeDefinitionCategoryTest']/td[2]/div/select")).sendKeys(Keys.RETURN); for an easy fix. However there are other ways to select by the value. Select select = new Select(driver.findElement(By.xpath(".//[@id='ctl04_Pane2_AttributeDefinitionCategoryTest']/td[2]/div/select"))); select.selectByVisibleText("Insert Text Here");



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2