Input

Page being translated from English to Japanese. Do you speak Japanese? Help us to translate it by sending us pull requests!

This section contains the APIs related to input commands.

Perform Actions

Selenium v4.17

        Actions selectThreeOptions =
                actions.click(options.get(1)).keyDown(Keys.SHIFT).click(options.get(3)).keyUp(Keys.SHIFT);

        input.perform(windowHandle, selectThreeOptions.getSequences());

Selenium v4.17

  it 'sends keyboard input' do
    driver.navigate.to 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html'

    input_field = driver.find_element(id: 'textInput')
    input_field.send_keys('Hello World')

    expect(input_field.attribute('value')).to eq('Hello World')
  end

Selenium v4.17

    const actions = driver.actions().click(options[1]).keyDown(Key.SHIFT).click(options[3]).keyUp(Key.SHIFT).getSequences()

    await input.perform(browsingContextId, actions)

Selenium v4.17

    driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html")

    input_field = driver.find_element(id="textInput")
    input_field.send_keys("Hello World")

    assert input_field.get_attribute("value") == "Hello World"


@pytest.mark.driver_type("bidi")
def test_input_mouse_click(driver):
    driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html")

    button = driver.find_element(id="consoleLog")
    button.click()

    # Verify click occurred
    assert button is not None

Release Actions

Selenium v4.17

        Actions sendLowercase =
                new Actions(driver).keyDown(inputTextBox, "a").keyDown(inputTextBox, "b");

        input.perform(windowHandle, sendLowercase.getSequences());
        ((JavascriptExecutor) driver).executeScript("resetEvents()");

        input.release(windowHandle);

Selenium v4.17


    input_field = driver.find_element(id: 'textInput')
    input_field.send_keys('a')

    expect(input_field.attribute('value')).to include('a')
  end

  it 'clicks element' do
    driver.navigate.to 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html'

    button = driver.find_element(id: 'consoleLog')
    button.click

Selenium v4.17

    await input.release(browsingContextId)

Selenium v4.17


@pytest.mark.driver_type("bidi")
def test_dispatch_keyboard_events(driver):
    driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html")

    driver.execute_script("""
        document.addEventListener('keydown', function(e) {
            console.log('Key pressed: ' + e.key);
        });
    """)

    body = driver.find_element(tag_name="body")
    body.send_keys("a")


@pytest.mark.driver_type("bidi")
def test_dispatch_mouse_events(driver):
    driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html")
最終更新 May 13, 2026: Add more examples (258c5519a6)