Can't switch control on elements of a chatbot using selenium in python
I am trying to send a message as input to chatbot to check the response but when I am trying to send a message to a chatbot, I need to click on the input box where one can enter a message. But it is showing 'element not found error' (In the code I am throwing NoSuchElement exception) I think this is happening because of the driver not being able to switch control from the base webpage to the chatbot after we click on the chatbot.
Following is the snippet:
driver.find_element_by_xpath('/html/body/div/div').click() time.sleep(2) try: driver.find_element_by_xpath('/html/body/div/div/div/div/textarea').click().send_keys('hi')except NoSuchElementException:print('Input element not found')
I am not real expert in python but I think you are trying to make two action on single line using .click() and .send_key at the same time. I believe you should try something like
Fills out the login page
elem= driver.find_element_by_xpath('/html/body/div/div/div/div/textarea') elem.send_keys('hi')
If you can share the page you are trying to automate I could have a deeper look might be some layer overriding your text area or the chat box is not in the view you need to scroll it up. Check the page here