我正在为论坛创建测试,我想测试论坛的BB代码。我有这样的BB代码,
[B][FONT=Trebuchet MS][SIZE=7]Meteor[/SIZE][/FONT][/B]
[COLOR=#000000][FONT=Verdana][I][B][SIZE=4]n: [/B][/I][/FONT]
[S][B][FONT=Verdana]ki[/SIZE][/FONT][/B][/S][/COLOR]
[URL='https:///coral-lps-6/']
[FONT=Impact][SIZE=7][COLOR=#F41600][U]CLICK HERE TO BUY![/U][/COLOR][/SIZE][/FONT][/URL]
我正尝试通过以下方式将此代码填充到文本区域(用p标签包裹)
messageBox = self.browser.find_elements_by_css_selector('.message-editorWrapper p')[0]
code = r"{}".format(bb_code)
self.browser.execute_script("arguments[0].innerHTML = '"+code+"'",messageBox)
我收到此错误
回溯(最近一次通话最后一次):文件“ login.py”,第51行,在 bot.postRequest()在postRequest中的文件“ login.py”,第31行 self.browser.execute_script(“ arguments [0] .innerHTML ='” + code +“'”,messageBox)文件 “ /usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py”, 第636行,在execute_script中 'args':convert_args})['value']文件“ /usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py”, 第321行,在执行中 self.error_handler.check_response(响应)文件“ /usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py”, 第242行,在check_response中 引发exception_class(消息,屏幕,堆栈跟踪)selenium.common.exceptions.WebDriverException:消息:未知错误: Runtime.evaluate引发异常:SyntaxError:无效或意外 令牌(会话信息:chrome = 70.0.3538.77)(驱动程序信息: chromedriver = 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),平台= Linux 4.15.0-66-通用x86_64)
但是当我使用简单的文本就可以了。因此,我如何在论坛中添加BB代码以测试硒是否有效?