Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Selenium | リストボックスの操作

概要

リストボックスの操作

詳細

リストボックスの操作について

操作例

driver = Selenium::WebDriver.for :firefox
driver.get "some_address"

# idがsome_idのリストボックスをアクティブ化
selectbox = driver.find_element(:id => "some_id")
selectbox.click
# リストの中からテキストに「Tokyo」を含む要素を選択
selectbox.find_elements(:tag_name => "option").find {|option|option.text.include? "Tokyo"}.click