Selenium Select - Selecting dropdown option by part of the text

前端 未结 8 1899
清歌不尽
清歌不尽 2020-12-19 16:57

The class Selenium Select has 3 methods of different option selection:

  1. selectByIndex
  2. selectByValue
  3. selectByVisibleText

Now,

8条回答
  •  半阙折子戏
    2020-12-19 17:24

    This is what I used to solve the issue in python.

    I used this option, so it selects the text that uses the word DOLLAR instead of typing the whole word as the value.

    Select(driver.find_element_by_name(ELEMENT)).select_by_value("DOLLAR")
    

    instead of

    Select(driver.find_element_by_name(ELEMENT)).select_by_visible_text(text)
    

提交回复
热议问题