weddriver处理富文本框



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会直接覆盖当前文本