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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -