Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Selenium2Driver.php

function Selenium2Driver::charToOptions

Creates some options for key events

Parameters

string|int $char the character or code:

KeyModifier::*|null $modifier:

Return value

string a json encoded options array for Syn

Throws

DriverException

3 calls to Selenium2Driver::charToOptions()
Selenium2Driver::keyDown in vendor/lullabot/mink-selenium2-driver/src/Selenium2Driver.php
Pressed down specific keyboard key.
Selenium2Driver::keyPress in vendor/lullabot/mink-selenium2-driver/src/Selenium2Driver.php
Presses specific keyboard key.
Selenium2Driver::keyUp in vendor/lullabot/mink-selenium2-driver/src/Selenium2Driver.php
Pressed up specific keyboard key.

File

vendor/lullabot/mink-selenium2-driver/src/Selenium2Driver.php, line 270

Class

Selenium2Driver
Selenium2 driver.

Namespace

Behat\Mink\Driver

Code

protected static function charToOptions($char, ?string $modifier = null) {
    if (is_int($char)) {
        $charCode = $char;
        $char = chr($charCode);
    }
    else {
        $charCode = ord($char);
    }
    $options = array(
        'key' => $char,
        'which' => $charCode,
        'charCode' => $charCode,
        'keyCode' => $charCode,
    );
    if ($modifier) {
        $options[$modifier . 'Key'] = true;
    }
    $json = json_encode($options);
    if ($json === false) {
        throw new DriverException('Failed to encode options: ' . json_last_error_msg());
    }
    return $json;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal