Skip to content

Commit 51fc959

Browse files
gravityvidiemolpujagani
authored
[Javascript] Split String on grapheme pairs in sendKeys command (#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 <[email protected]> Co-authored-by: Puja Jagani <[email protected]>
1 parent c5ff607 commit 51fc959

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

javascript/node/selenium-webdriver/lib/webdriver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ class WebElement {
25302530

25312531
// The W3C protocol requires keys to be specified as an array where
25322532
// each element is a single key.
2533-
keys.push(...key.split(''))
2533+
keys.push(...key)
25342534
})
25352535

25362536
if (!this.driver_.fileDetector_) {

javascript/node/selenium-webdriver/test/lib/webdriver_test.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,9 @@ describe('WebDriver', function () {
257257
.andReturnError(new StubError())
258258
.end()
259259

260-
const driver = WebDriver.createSession(executor,
261-
{ browserName: 'firefox' })
260+
const driver = WebDriver.createSession(executor, {
261+
browserName: 'firefox',
262+
})
262263
return driver.getSession().then(fail, assertIsStubError)
263264
})
264265

@@ -334,7 +335,7 @@ describe('WebDriver', function () {
334335
let verifyError = expectedError(
335336
error.NoSuchSessionError,
336337
'This driver instance does not have a valid session ID ' +
337-
'(did you call WebDriver.quit()?) and may no longer be used.'
338+
'(did you call WebDriver.quit()?) and may no longer be used.'
338339
)
339340

340341
let driver = executor.createDriver()
@@ -522,14 +523,14 @@ describe('WebDriver', function () {
522523
let executor = new FakeExecutor()
523524
.expect(CName.EXECUTE_SCRIPT)
524525
.withParameters({
525-
script: 'return (' + function () { } + ').apply(null, arguments);',
526+
script: 'return (' + function () {} + ').apply(null, arguments);',
526527
args: [],
527528
})
528529
.andReturnSuccess(null)
529530
.end()
530531

531532
const driver = executor.createDriver()
532-
return driver.executeScript(function () { })
533+
return driver.executeScript(function () {})
533534
})
534535

535536
it('simpleArgumentConversion', function () {
@@ -629,23 +630,23 @@ describe('WebDriver', function () {
629630
let executor = new FakeExecutor()
630631

631632
const arg = Promise.reject(new StubError())
632-
arg.catch(function () { }) // Suppress default handler.
633+
arg.catch(function () {}) // Suppress default handler.
633634

634635
const driver = executor.createDriver()
635636
return driver
636-
.executeScript(function () { }, arg)
637+
.executeScript(function () {}, arg)
637638
.then(fail, assertIsStubError)
638639
})
639640
})
640641

641642
describe('executeAsyncScript', function () {
642643
it('failsIfArgumentIsARejectedPromise', function () {
643644
const arg = Promise.reject(new StubError())
644-
arg.catch(function () { }) // Suppress default handler.
645+
arg.catch(function () {}) // Suppress default handler.
645646

646647
const driver = new FakeExecutor().createDriver()
647648
return driver
648-
.executeAsyncScript(function () { }, arg)
649+
.executeAsyncScript(function () {}, arg)
649650
.then(fail, assertIsStubError)
650651
})
651652
})
@@ -939,6 +940,21 @@ describe('WebDriver', function () {
939940
return element.sendKeys(1, 2, 'abc', 3)
940941
})
941942

943+
it('sendKeysWithEmojiRepresentedByPairOfCodePoints', function () {
944+
let executor = new FakeExecutor()
945+
.expect(CName.SEND_KEYS_TO_ELEMENT, {
946+
id: WebElement.buildId('one'),
947+
text: '\uD83D\uDE00',
948+
value: ['\uD83D\uDE00'],
949+
})
950+
.andReturnSuccess()
951+
.end()
952+
953+
const driver = executor.createDriver()
954+
const element = new WebElement(driver, 'one')
955+
return element.sendKeys('\uD83D\uDE00')
956+
})
957+
942958
it('convertsVarArgsIntoStrings_promisedArgs', function () {
943959
let executor = new FakeExecutor()
944960
.expect(CName.FIND_ELEMENT, {
@@ -1927,7 +1943,7 @@ describe('WebDriver', function () {
19271943
})
19281944

19291945
it('passes through function properties', function () {
1930-
function bar() { }
1946+
function bar() {}
19311947
return runDeserializeTest(
19321948
[{ foo: { bar: 123 }, func: bar }],
19331949
[{ foo: { bar: 123 }, func: bar }]

0 commit comments

Comments
 (0)