python,selenium,发送linebreak给tinym

2024-04-24 22:59:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我要在tinymce文本框中发布以下代码:

driver.get("http://www.tinymce.com/tryit/full.php")
driver.execute_script("tinyMCE.activeEditor.insertContent('%s')" % "hel\nlo\n\n")

当发送不带换行符的普通字符串时,它可以很好地工作,但是当添加换行符时,它会抛出异常:

^{pr2}$

这是由于一个无效字符造成的。如何将换行符发送到tinymce文本区域(不使用sendkeys命令)?


Tags: 代码comhttpexecutegetwwwdriverscript