lino-levan / astral

A high-level puppeteer/playwright-like library for Deno
https://jsr.io/@astral/astral
MIT License
176 stars 7 forks source link

`page.keyboard.press("Tab")` input "Tab" as text #57

Open jeiea opened 2 months ago

jeiea commented 2 months ago

Steps to reproduce

import { launch } from "https://deno.land/x/astral@0.3.5/mod.ts";
const browser = await launch();
const page = await browser.newPage('https://google.com');
await page.keyboard.type("Tab");

Expected behavior

Press tab key

Actual behavior

Type "Tab"

lino-levan commented 2 months ago

Does await page.keyboard.type("\t"); work?

jeiea commented 2 months ago
import { launch } from "https://deno.land/x/astral@0.3.5/mod.ts";
const browser = await launch();
const page = await browser.newPage(
  "https://news.ycombinator.com/login?goto=news",
);
await page.keyboard.type("a\tb\tc\td");

image

lino-levan commented 2 months ago

Hm, appears to work?

jeiea commented 2 months ago

Expected behavior in that case is focus movement, so

a
b
c
d
lino-levan commented 2 months ago

Is the expected behavior consistent with the behavior of other tools (e.g. puppeteer, playwright, etc)? Perhaps we could have something like page.accessibility.tabNext()?

jeiea commented 2 months ago

I don't know about puppeteer or playwright behavior, so I simply used "Tab" because it was type hinted.

However, I have noticed other constants present there. If you decide to add tabNext, you should first remove that hint.

lino-levan commented 2 months ago

Ah okay, right. This is a bug with my implementation. Will fix, thank you. Not sure what it would actually do, but it should just work.