【发布时间】:2020-05-09 02:22:02
【问题描述】:
当我将字符串传递给包含 HTML 的 send_keys 时遇到问题。这一切都在转变。例如,<tag>abc</tag>def 变为 <tag>c</tagdef>。文本字段由以下内容描述:
<textarea maxlength="4000" id="some-id" rows="3" name="data[a][b]" class="a-form-normal" dir="auto" spellcheck="true"></textarea>
我真的不明白会发生什么以及如何避免它。我通常通过以下方式传递我的 html 字符串:
description = '<tag>abc</tag>def'
browser.find_element_by_id('some-id).send_keys(description)
这会导致奇怪的变化,如上所述。
相反,我尝试粘贴字符串:
os.system("echo %s| clip" % description.strip())
browser.find_element_by_id('some-id').send_keys(Keys.CONTROL,'v')
然后我收到错误消息:语法错误:重定向意外
我在树莓派上使用 Python 3.7
非常感谢您的帮助
【问题讨论】:
-
你能添加这个文本正在发送的文本字段的html吗?
-
@Jortega 添加了
<textarea maxlength="4000" id="some-id" rows="3" name="data[a][b]" class="a-form-normal" dir="auto" spellcheck="true"></textarea>
标签: python selenium selenium-chromedriver