As you mentioned send_keys("TEST")
are not working, there are a couple of alternatives to send a character sequence
to respective fields as mentioned below :
-
Use
Keys.NUMPAD3
[simulatingsend_keys("3")
]:login.send_keys(Keys.NUMPAD3)
-
Use
JavascriptExecutor
withgetElementById
:self.driver.execute_script("document.getElementById('login_email').value="12345"")
-
Use
JavascriptExecutor
withgetElementsById
:self.driver.execute_script("document.getElementsById('login_password')[0].value="password"")
Now comming to your specific issue, as you mentioned I tried to use clear() or click() before sendkeys but nothing works correctly
, so we will take help of javascript
to click()
on the text area to clear the predefined text
and then use send_keys
to populate the text field as follows:
self.driver.execute_script("document.getElementById('manage_description').click()")
self.driver.find_element_by_id('manage_description').send_keys("TEST")
Update :
As you mentioned sometimes it works sometimes not, so I would suggest the following:
- Induce
ExplicitWait
fortextarea
to be clickable. - Use
javascript
to send thetext
within thetextarea
too. -
Your code will look like:
my_string = "TEST"; elem = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "manage_description"))) self.driver.execute_script("document.getElementById('manage_description').click()") self.driver.execute_script("arguments[0].setAttribute('value', '" + my_string +"')", elem);