Reputation: 579
How is it possible to send keys to an editable body in an iframe?
Page:
<iframe id="description_ifr" frameborder="0" allowtransparency="true" title="Rich Text Area..." src="javascript:""" style="width: 100%; height: 200px; display: block;"><html><head>...</head><body id="tinymce" class="mce-content-body " data-id="description" contenteditable="true" spellcheck="false" style="min-height: 184px;"><br data-mce-bogus="1"></body></html></iframe>
Code I tried:
description = browser.find_element_by_id('tinymce')
description.click()
description.send_keys("Test")
Error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="tinymce"]"}
Upvotes: 0
Views: 581
Reputation: 1938
You should switch to the iframe before sending text.
try,
browser.switch_to_frame(browser.find_element_by_id('description_ifr'))
description = browser.find_element_by_id('tinymce')
description.click()
description.send_keys("Test")
Upvotes: 2