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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/lib/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2530,7 +2530,7 @@ class WebElement {

// The W3C protocol requires keys to be specified as an array where
// each element is a single key.
keys.push(...key.split(''))
keys.push(...key)
})

if (!this.driver_.fileDetector_) {
Expand Down
36 changes: 26 additions & 10 deletions javascript/node/selenium-webdriver/test/lib/webdriver_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ describe('WebDriver', function () {
.andReturnError(new StubError())
.end()

const driver = WebDriver.createSession(executor,
{ browserName: 'firefox' })
const driver = WebDriver.createSession(executor, {
browserName: 'firefox',
})
return driver.getSession().then(fail, assertIsStubError)
})

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

let driver = executor.createDriver()
Expand Down Expand Up @@ -522,14 +523,14 @@ describe('WebDriver', function () {
let executor = new FakeExecutor()
.expect(CName.EXECUTE_SCRIPT)
.withParameters({
script: 'return (' + function () { } + ').apply(null, arguments);',
script: 'return (' + function () {} + ').apply(null, arguments);',
args: [],
})
.andReturnSuccess(null)
.end()

const driver = executor.createDriver()
return driver.executeScript(function () { })
return driver.executeScript(function () {})
})

it('simpleArgumentConversion', function () {
Expand Down Expand Up @@ -629,23 +630,23 @@ describe('WebDriver', function () {
let executor = new FakeExecutor()

const arg = Promise.reject(new StubError())
arg.catch(function () { }) // Suppress default handler.
arg.catch(function () {}) // Suppress default handler.

const driver = executor.createDriver()
return driver
.executeScript(function () { }, arg)
.executeScript(function () {}, arg)
.then(fail, assertIsStubError)
})
})

describe('executeAsyncScript', function () {
it('failsIfArgumentIsARejectedPromise', function () {
const arg = Promise.reject(new StubError())
arg.catch(function () { }) // Suppress default handler.
arg.catch(function () {}) // Suppress default handler.

const driver = new FakeExecutor().createDriver()
return driver
.executeAsyncScript(function () { }, arg)
.executeAsyncScript(function () {}, arg)
.then(fail, assertIsStubError)
})
})
Expand Down Expand Up @@ -939,6 +940,21 @@ describe('WebDriver', function () {
return element.sendKeys(1, 2, 'abc', 3)
})

it('sendKeysWithEmojiRepresentedByPairOfCodePoints', function () {
let executor = new FakeExecutor()
.expect(CName.SEND_KEYS_TO_ELEMENT, {
id: WebElement.buildId('one'),
text: '\uD83D\uDE00',
value: ['\uD83D\uDE00'],
})
.andReturnSuccess()
.end()

const driver = executor.createDriver()
const element = new WebElement(driver, 'one')
return element.sendKeys('\uD83D\uDE00')
})

it('convertsVarArgsIntoStrings_promisedArgs', function () {
let executor = new FakeExecutor()
.expect(CName.FIND_ELEMENT, {
Expand Down Expand Up @@ -1927,7 +1943,7 @@ describe('WebDriver', function () {
})

it('passes through function properties', function () {
function bar() { }
function bar() {}
return runDeserializeTest(
[{ foo: { bar: 123 }, func: bar }],
[{ foo: { bar: 123 }, func: bar }]
Expand Down