Method: Playwright::Page#select_option

Defined in:
lib/playwright_api/page.rb

#select_option(selector, element: nil, index: nil, value: nil, label: nil, noWaitAfter: nil, timeout: nil) ⇒ Object

Returns the array of option values that have been successfully selected.

Triggers a change and input event once all the provided options have been selected. If there’s no ‘<select>` element matching selector, the method throws an error.

Will wait until all specified options are present in the ‘<select>` element.

“‘js // single selection matching the value page.selectOption(’select#colors’, ‘blue’);

// single selection matching the label page.selectOption(‘select#colors’, { label: ‘Blue’ });

// multiple selection page.selectOption(‘select#colors’, [‘red’, ‘green’, ‘blue’]);

“‘

“‘python async # single selection matching the value await page.select_option(“select#colors”, “blue”) # single selection matching the label await page.select_option(“select#colors”, label=“blue”) # multiple selection await page.select_option(“select#colors”, value=[“red”, “green”, “blue”]) “`

“‘python sync # single selection matching the value page.select_option(“select#colors”, “blue”) # single selection matching both the label page.select_option(“select#colors”, label=“blue”) # multiple selection page.select_option(“select#colors”, value=[“red”, “green”, “blue”]) “`

Shortcut for main frame’s [‘method: Frame.selectOption`]



1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
# File 'lib/playwright_api/page.rb', line 1298

def select_option(
      selector,
      element: nil,
      index: nil,
      value: nil,
      label: nil,
      noWaitAfter: nil,
      timeout: nil)
  wrap_impl(@impl.select_option(unwrap_impl(selector), element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
end