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

[Javascript] Split String on grapheme pairs in sendKeys command #10519

Merged
merged 6 commits into from
Apr 11, 2022

Conversation

gravityvi
Copy link
Contributor

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

  • split string on grapheme pairs under sendKeys command

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@CLAassistant
Copy link

CLAassistant commented Apr 6, 2022

CLA assistant check
All committers have signed the CLA.

@harsha509
Copy link
Member

Hi @gravityvi,

Thanks for the PR.

I tried passing ele.sendKeys(:grinning:) and ele.sendKeys(\uD83D\uDE00);

With your changes I get the below error

WebDriverError: unknown error: ChromeDriver only supports characters in the BMP

@sonarcloud
Copy link

sonarcloud bot commented Apr 11, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@pujagani
Copy link
Contributor

pujagani commented Apr 11, 2022

Java

I tried the following code snippet in Java:

 driver.get("https://google.com"); 
 driver.findElement(By.name("q")).sendKeys("\uD83D\uDCA9");

I see the same error as Harsha reported when using ChromeDriver:

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: ChromeDriver only supports characters in the BMP

However, it is a known ChromeDriver bug.

I double-checked with FirefoxDriver and it works as expected.

Javascript

I ran a similar test snippet in Javascript:

await driver.get('https://www.google.com');
await driver.findElement(By.name('q')).sendKeys('💩');

Before the changes in this PR:

FirefoxDriver shows the error:
InvalidArgumentError: Failed to decode request as JSON: {"text":"💩","value":["\ud83d","\udca9"]}

ChromeDriver shows a vague error and stack trace.

After the changes in this PR:

FirefoxDriver works as expected with the emoji.

ChromeDriver shows the error:

WebDriverError: unknown error: ChromeDriver only supports characters in the BMP
  (Session info: chrome=100.0.4896.75)

@harsha509 Hence, the error we encountered is not related to this PR.

Copy link
Member

@harsha509 harsha509 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @gravityvi !

@harsha509 harsha509 merged commit 51fc959 into SeleniumHQ:trunk Apr 11, 2022
@gravityvi gravityvi deleted the issue10518 branch April 12, 2022 04:12
elgatov pushed a commit to elgatov/selenium that referenced this pull request Jun 27, 2022
…niumHQ#10519)

* split string on grapheme pairs in sendKeys

* added test for using emoji representated by pair of code points as sendKeys argument

Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
Co-authored-by: Puja Jagani <puja.jagani93@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: Split on grapheme pairs while using sendKeys
5 participants