千家信息网

weddriver处理富文本框

发表于:2024-10-24 作者:千家信息网编辑
千家信息网最后更新 2024年10月24日,通过运行js,这种方法能处理各种疑难问题.代码如下://设置js的运行方法def input_content(self,content):js = "document.getElementById('
千家信息网最后更新 2024年10月24日weddriver处理富文本框




通过运行js,这种方法能处理各种疑难问题.代码如下:

//设置js的运行方法

def input_content(self,content):

js = "document.getElementById('content_ifr').contentWindow.document.body.innerText = 'admin'"//contentWindow对firefox最新版本支持不好

return self.dr.execute_script(js)


js = "document.getElementsByClassName('ke-edit-iframe')[0].contentDocument.body.innerText='admin'"

js = "document.getElementById('content_ifr').contentDocument.write('admin');" //write会在文本后面继续写,inner会直接覆盖当前文本




0