import selenium_driverless.webdriver as webdriver
import asyncio
async def main():
async with webdriver.Chrome(options=webdriver.ChromeOptions()) as driver:
await driver.get('https://demoqa.com/text-box')
textarea = await driver.find_elements(By.XPATH, '//textarea')
await textarea[0].send_keys("Hello\nWorld!")
asyncio.run(main())
Running this raises an error
Traceback:
Traceback (most recent call last): File "d:\Codes\PY\test_textarea.py", line 14, in <module> asyncio.run(main()) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "d:\Codes\PY\School\SPARK\test_textarea.py", line 11, in main await textarea[0].send_keys("Hello\nWorld!") File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium_driverless\types\webelement.py", line 567, in send_keys await self.__target__.send_keys(text) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium_driverless\types\target.py", line 463, in send_keys await self.execute_cdp_cmd("Input.dispatchKeyEvent", key_event) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium_driverless\types\target.py", line 1106, in execute_cdp_cmd result = await self.socket.exec(method=cmd, params=cmd_args, timeout=timeout) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\site-packages\cdp_socket\socket.py", line 85, in exec res = await asyncio.wait_for(self._responses[_id], timeout=timeout) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 445, in wait_for return fut.result() cdp_socket.exceptions.CDPError: {'code': -32602, 'message': 'Invalid parameters', 'data': 'Failed to deserialize params.code - BINDINGS: string value expected at position 26'}
Running this raises an error Traceback:
Traceback (most recent call last): File "d:\Codes\PY\test_textarea.py", line 14, in <module> asyncio.run(main()) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "d:\Codes\PY\School\SPARK\test_textarea.py", line 11, in main await textarea[0].send_keys("Hello\nWorld!") File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium_driverless\types\webelement.py", line 567, in send_keys await self.__target__.send_keys(text) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium_driverless\types\target.py", line 463, in send_keys await self.execute_cdp_cmd("Input.dispatchKeyEvent", key_event) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium_driverless\types\target.py", line 1106, in execute_cdp_cmd result = await self.socket.exec(method=cmd, params=cmd_args, timeout=timeout) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\site-packages\cdp_socket\socket.py", line 85, in exec res = await asyncio.wait_for(self._responses[_id], timeout=timeout) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 445, in wait_for return fut.result() cdp_socket.exceptions.CDPError: {'code': -32602, 'message': 'Invalid parameters', 'data': 'Failed to deserialize params.code - BINDINGS: string value expected at position 26'}
It seems like ENTER key was not implemented.