grafana / xk6-browser

The browser module adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol to k6.
https://grafana.com/docs/k6/latest/javascript-api/k6-browser/
GNU Affero General Public License v3.0
343 stars 41 forks source link

Input of special characters not working #132

Closed tom-miseur closed 2 years ago

tom-miseur commented 2 years ago

Looks like we omit "@" in this example:

import launcher from 'k6/x/browser';

export default function () {
  const browser = launcher.launch('chromium', {
    headless: __ENV.XK6_HEADLESS ? true : false,
    slowMo: '500ms' // slow down by 500ms
  });
  const context = browser.newContext();
  const page = context.newPage();

  page.goto('http://ecommerce.test.k6.io/my-account/', { waitUntil: 'networkidle' });

  page.$('#username').type('test@k6.io');

  page.waitForTimeout(5000);
}
stephan-procore commented 2 years ago

Following as we need the ability to enter special characters. Happy to assist with any forthcoming fixes.

arundhatid commented 2 years ago

Is there any workaround till we find a fix?

inancgumus commented 2 years ago

@arundhatid Here's the workaround until we fix it:

page.focus('#username');
page.keyboard.insertText('test@k6.io');
arundhatid commented 2 years ago

Yes. that works. Thanks

tom-miseur commented 2 years ago

Is this due to typ using Playwright's press instead of type or insertText?

Removing "@" from the us,go keyboardlayout causes typ to use insertText and that works.

Seems @inancgumus is on it already in #134

inancgumus commented 2 years ago

@tom-miseur when you use insertText, it doesn't emit any key up/down events because it fills the input box without pressing any keys from the browser side.