Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unicode support in appendSlowly method #907

Merged
merged 1 commit into from
Jul 14, 2021

Conversation

overlord-space
Copy link
Contributor

Currently, if we use for example Cyrillic symbols in typeSlowly or appendSlowly methods, they are processed with str_split function, which does not correctly processes unicode characters.

str_split('Образец')

will return:

array:14 [
  0 => b"Ð"
  1 => b"ž"
  2 => b"Ð"
  3 => b"±"
  4 => b"Ñ"
  5 => b""
  6 => b"Ð"
  7 => b"°"
  8 => b"Ð"
  9 => b"·"
  10 => b"Ð"
  11 => b"µ"
  12 => b"Ñ"
  13 => b""
]

After that, web-driver will send the sendKeysToElement command with parameters similar as follows: "�" instead of {"text":"О",":id": ...}

Server will respond to this request with the following exception: "invalid argument: missing command parameters".

Replacing str_split with mb_str_split (PHP >= 7.4) or with preg_split('\\u', ...) fix this issue.

preg_split('//u', 'Образец', -1, PREG_SPLIT_NO_EMPTY)

=> array:7 [
  0 => "О"
  1 => "б"
  2 => "р"
  3 => "а"
  4 => "з"
  5 => "е"
  6 => "ц"
]

And server will receive correct command parameters:
sendKeysToElement || {"text":"\u0430",":id": ...}

Replace str_split with preg_split for support unicode
@taylorotwell taylorotwell merged commit d44ebcb into laravel:6.x Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants