0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Seleniumでプルダウンメニューから任意の値を選択するには

0
Posted at

環境

Ruby3.3

はじめに

Seleniumでプルダウンメニューから任意の値を選択することは、そう簡単にはできません。listから任意の値を選択したり、bottonをクリックしたり、textに値を入力したりといったやり方とは少し勝手が異なる方法で実現させることになります。

参考

コード

driverの変数を定義します。

sample.rb
driver = Selenium::WebDriver.for :chrome

HTMLのSelectで設定しているnameを指定します。この例では「listid」です。nameの代わりに、idを指定しても実現は可能です。

Selectで定義している数あるメニューの中から「一覧表」を選択します。

sample.rb
select = Selenium::WebDriver::Support::Select.new(driver.find_element(name: 'listid'))
select.select_by(:text, "一覧表")
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?