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

[BUG] Webkit clears on page.type – Chromium/Firefox don't #2702

Closed
arjunattam opened this issue Jun 25, 2020 · 5 comments · Fixed by #3141
Closed

[BUG] Webkit clears on page.type – Chromium/Firefox don't #2702

arjunattam opened this issue Jun 25, 2020 · 5 comments · Fixed by #3141
Assignees

Comments

@arjunattam
Copy link
Contributor

arjunattam commented Jun 25, 2020

Context:

  • Playwright Version: 1.1.1 and next
  • Operating System: Windows and Mac
  • Browser: Webkit

Code Snippet

const {webkit} = require('playwright');

(async () => {
    const browser = await webkit.launch({headless: false, slowMo: 100});
    const context = await browser.newContext();
    const page = await context.newPage();
    await page.setContent(`<input type="text" id="example" value="default" />`);
    await page.type('#example', 'text');
    await browser.close();
})();

Browser behaviors for input value:

  • Chromium: textdefault
  • Firefox: textdefault
  • Webkit: text

Should they behave consistently? Is webkit a bug?

@yury-s
Copy link
Member

yury-s commented Jun 25, 2020

I'd expect page.fill() to clear the old value, i.e. every browser behave like webkit does today.

@arjunattam
Copy link
Contributor Author

arjunattam commented Jun 25, 2020

@yury-s: I meant to share the snippet with page.type (not fill), which is behaving differently on webkit. Apologies for the confusion! I have edited the snippet

@JoelEinbinder
Copy link
Contributor

I'll take a look.

@JoelEinbinder JoelEinbinder self-assigned this Jun 25, 2020
@JoelEinbinder
Copy link
Contributor

So there is some real difference in the browser behavior here. In webkit, HTMLInputElement.focus() causes all of text to be selected. In Firefox and Chromium, it puts the cursor at the start of if the input field. However, all of the browsers are consistent when tabbing into an element. They select all of the text.

Right now our typing is implement as

type(element, text):
   focus(element)
   keyboard.type(text)

Maybe we should make our focus behave like keyboard focus, selecting the text. Maybe we are doing the correct thing, and users should expect/want this behavior to be different.

The spec unhelpfully says that this behavior is platform specific:

Apply any relevant platform-specific conventions for focusing new focus target. (For example, some platforms select the contents of a text control when that control is focused.)

@pavelfeldman
Copy link
Member

I'd say consistency is what is important. And since it is probably easier to select all the text than unselect it, I'd do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants