I'm trying to comment on instagram with selenium just for testing, but I'm not able to type inside the textarea, follow the part of the code.
comentar = driver.find_element_by_tag_name('textarea')
comentar.clear()
comentar.send_keys('Comentario')
I'm having to use it.
keyboard.type("@Fabiany_Hey")
keyboard.press(Key.enter)
But only type if the window is in focus.
The first code returns this error.
Traceback (most recent call last):
File "C:\Users\Pichau\Desktop\Teste.py", line 24, in <module>
comentar.send_keys('Comentario')
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 479, in send_keys
'value': keys_to_typing(value)})
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=66.0.3359.139)
(Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.16299 x86_64)
HTML:
<textarea aria-label="Adicione um comentário..." placeholder="Adicione um comentário..." class="_bilrf" autocomplete="off" autocorrect="off"></textarea>
I'm using python 3.6