Skip to content

Commit 919a128

Browse files
miraokobenguyent
authored andcommitted
fix(playwright): always use keyboard.type for strings, add national characters test (#5280)
1 parent d18c708 commit 919a128

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/helper/Playwright.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2392,11 +2392,15 @@ class Playwright extends Helper {
23922392
* {{> type }}
23932393
*/
23942394
async type(keys, delay = null) {
2395+
// Always use page.keyboard.type for any string (including single character and national characters).
23952396
if (!Array.isArray(keys)) {
23962397
keys = keys.toString()
2397-
keys = keys.split('')
2398+
const typeDelay = typeof delay === 'number' ? delay : this.options.pressKeyDelay
2399+
await this.page.keyboard.type(keys, { delay: typeDelay })
2400+
return
23982401
}
23992402

2403+
// For array input, treat each as a key press to keep working combinations such as ['Control', 'A'] or ['T', 'e', 's', 't'].
24002404
for (const key of keys) {
24012405
await this.page.keyboard.press(key)
24022406
if (delay) await this.wait(delay / 1000)

test/helper/Playwright_test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,15 @@ describe('Playwright', function () {
712712
})
713713
})
714714

715+
describe('#type', () => {
716+
it('should type national characters', async () => {
717+
await I.amOnPage('/form/field')
718+
await I.fillField('Name', '')
719+
await I.type('Oprávněné')
720+
await I.seeInField('Name', 'Oprávněné')
721+
})
722+
})
723+
715724
describe('#waitForEnabled', () => {
716725
it('should wait for input text field to be enabled', () =>
717726
I.amOnPage('/form/wait_enabled')

0 commit comments

Comments
 (0)