ClericPy / ichrome

Chrome controller for Humans, based on Chrome Devtools Protocol(CDP) and python3.7+.
https://pypi.org/project/ichrome/
MIT License
228 stars 29 forks source link

how to send a keyborad event ENTER,I didn't find any examples. #68

Closed wangjingyu001 closed 2 years ago

wangjingyu001 commented 2 years ago

await tab.keyboard_send(key='ENTER') {'id': 12, 'result': {}} await tab.keyboard_send(string='ENTER') {'id': 17, 'result': {}} await tab.keyboard_send(key='ENTER') {'id': 18, 'result': {}} await tab.keyboard_send(key='ENTER') {'id': 19, 'result': {}} await tab.keyboard_send(key='BACK') {'id': 20, 'result': {}} await tab.keyboard_send(key='ESPACE') {'id': 21, 'result': {}} await tab.keyboard_send(key='ESPACE') {'id': 22, 'result': {}} await tab.js('zl_tz(8906)') {'type': 'undefined'} none of theses can use.

ClericPy commented 2 years ago

Here is the cdp doc: https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchKeyEvent

PS: it only dispath the keyboard events but not the physical Keyboard.

await tab.keyboard_send(string='\r') could send Enter by the way.

wangjingyu001 commented 2 years ago

first ,I used tab.js('zl_tz(8906)') .It's a function that button calls. And ,I use '\r',It's easier. And one more question. How to deal with alert window. I used tab.historyback(). But sometimes it doesn't work well. So is there something that likes selenium switch to alert. THANKS.

ClericPy commented 2 years ago

Do you mean tab.handle_dialog ?