kaliiiiiiiiii / Selenium-Driverless

undetected Selenium without usage of chromedriver
https://kaliiiiiiiiii.github.io/Selenium-Driverless/
Other
404 stars 52 forks source link

[feature request] `send_keys` non-en_US keyboard layout support #207

Open namtacs opened 2 months ago

namtacs commented 2 months ago

For example: await input.send_keys("Иван") does nothing

here it checks if the char in present in mappings https://github.com/kaliiiiiiiiii/Selenium-Driverless/blob/99185863149526af0ab066c0e4043f57c556d5ef/src/selenium_driverless/types/target.py#L414 but if it isn't then it just silently ignores it. I suggest sending the appropriate keycodes for the selected keyboard layout, autogenerating mappings (somehow) or raising an error.

kaliiiiiiiiii commented 2 months ago

For example: await input.send_keys("Иван") does nothing

here it checks if the char in present in mappings

https://github.com/kaliiiiiiiiii/Selenium-Driverless/blob/99185863149526af0ab066c0e4043f57c556d5ef/src/selenium_driverless/types/target.py#L414

but if it isn't then it just silently ignores it. I suggest sending the appropriate keycodes for the selected keyboard layout, autogenerating mappings (somehow) or raising an error.

Yeah, at least an Exception would be expected indeed. My plan is (long-term), to implement different keyboard layouts. For now however, you might use elem.write() instead

EDIT

I'll be updating the US keyboard layout by using the following sources as a guideline

https://github.com/microsoft/playwright/issues/7396#issuecomment-1637150391 for reference on the keyboard layouts to support and generate_keyboard_layouts.js to generate keyboard layouts

boludoz commented 2 months ago

Add send_keys in a simple way and that's it or are you a psychopath?

boludoz commented 2 months ago

https://github.com/kaliiiiiiiiii/Selenium-Driverless/pull/191

kaliiiiiiiiii commented 2 months ago

Add send_keys in a simple way and that's it or are you a psychopath?

it's not just simple way. The code you've provided at https://github.com/kaliiiiiiiiii/Selenium-Driverless/pull/191/files#diff-eb355e1147cb9c933fac6232a336122a60ef8bafb5a2661496aeb58ba142f741R488 is highly detectable and doesn't even work when keydown//keyup events are required.