html - How to add text to a page using python selenium? -
i'm trying enter text text box using python selenium.
the html looks below:
<div class="sendbox placeholder" contenteditable="true" data-placeholder="type message or drop attachment..." id="sendmessage" style="height: 375px;"></div>
after manually typing 'test' text box, html looks this:
<div class="sendbox placeholder" contenteditable="true" data-placeholder="type message or drop attachment..." id="sendmessage" style="height: 375px;">test</div>
i've tried following code, there no response
driver.find_element_by_xpath("//div[@id='sendmessage']").send_keys("testing")
however, if manually click on text box cursor shows , enter in code, work. haven't been able figure out how make curser show via python selenium. i've tried below though.
driver.find_element_by_xpath("//div[@id='sendmessage']").click()
it sounds clicking , sending keys element should help:
element = driver.find_element_by_xpath("//div[@id='sendmessage']") element.click() element.send_keys("testing")
you can workaround setting innerhtml
via execute_script()
:
driver.execute_script("arguments[0].innerhtml = arguments[1];", element, "testing");
Comments
Post a Comment