Selecting dropdown in WebDriverJs

后端 未结 15 1170
星月不相逢
星月不相逢 2020-12-29 07:48

I have a dropdown box that I would like to select a value using WebDriverJS. I\'ve looked at the user guide below and could not find out how to do it

15条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 07:55

    Find the select element and click on it to display the dropdown

    driver.findElement(//div//select[@id="elementId"]).click();

    Then select from the options and click on it. I think selecting by xpath will really work better here.

    driver.findElement(By.xpath('//div//select[@id="elementId"]//option[optionIndex]')).click();

提交回复
热议问题