I'm running some tests for Django Channels that work when I do them manually but when I run the test via Selenium it does not seem to be pressing ENTER after it inputs the text (the text shows up fine), and if I press it on the keyboard from my side it works.
Code for the ActionChains function
def _post_message(self, message):
ActionChains(self.driver).send_keys(message, Keys.ENTER).perform()
Not sure whether its related but the logs show me the following ERROR as well:
[10864:2712:0105/185426.868:ERROR:device_event_log_impl.cc(215)] [18:54:26.867] USB: usb_device_handle_win.cc:1045 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
Thank you
Tried using RETURN instead of ENTER and also doing the text input and send key as separate commands.
CodePudding user response:
Looks like the send_key(Keys.ENTER)
return was too quick and as such the key was not getting pressed in time before the field was actually filled.
I used a for loop with a small timer and alas it worked.
def _post_message(self, message):
action = ActionChains(self.driver)
for letter in message:
action.send_keys(letter)
time.sleep(0.5)
action.send_keys(Keys.ENTER).perform()