在python中,如何通过splinter或selenium向标记发送密钥?

在python中,如何通过splinter或selenium向标记发送密钥?,python,selenium,automation,beautifulsoup,splinter,Python,Selenium,Automation,Beautifulsoup,Splinter,我试图填充一个使用按键事件的消息框,现在我能够找到带有Splitter的消息框,因此消息框div通常为: <div aria-autocomplete="list" aria-controls="js_7" aria- describedby="placeholder-cmsmo" aria-expanded="false" aria-label="Type a message..." class="notranslate _5rpu" contenteditabl

我试图填充一个使用按键事件的消息框,现在我能够找到带有Splitter的消息框,因此消息框div通常为:

       <div aria-autocomplete="list" aria-controls="js_7" aria-
    describedby="placeholder-cmsmo" aria-expanded="false" aria-label="Type
 a message..." class="notranslate _5rpu" contenteditable="true" 
role="combobox" spellcheck="true" tabindex="0" style="outline: none; user-
select: text; white-space: pre-wrap; word-wrap: break-word;"><div data-
contents="true"><div class="" data-block="true" data-editor="cmsmo" data-
offset-key="7qui-0-0"><div data-offset-key="7qui-0-0" class="_1mf _1mj">
<span data-offset-key="7qui-0-0"><br data-text="true"></span></div></div>
</div></div>
结果:

98vvu-0-0
这意味着我现在已经找到了span标记,如何通过splinter或selenium发送键来填充span标记之间的内容,以便在消息框中自动键入

我尝试了以下两种方法:

    <div aria-autocomplete="list" aria-controls="js_7" aria-
expanded="false" aria-label="Type a message..." class="notranslate _5rpu"
 contenteditable="true" role="combobox" spellcheck="true" tabindex="0" 
style="outline: none; user-select: text; white-space: pre-wrap; word-wrap: 
break-word;"><div data-contents="true"><div class="" data-block="true" 
data-editor="cmsmo" data-offset-key="98vvu-0-0"><div data-offset-
key="98vvu-0-0" class="_1mf _1mj"><span data-offset-key="98vvu-0-0"><span 
data-text="true">hello this is example text</span></span></div></div></div>
</div>
span_tag=browser.find_by_xpath(d1)


span_tag.send_keys("hello this is example")
第二

span_tag=browser.find_by_xpath(d1)




for i in span_tag:
    print(i.send_keys("hello this is example"))
但在这两种情况下,我都会遇到这样的错误:

Traceback (most recent call last):
  File "/anaconda/lib/python3.5/site-packages/splinter/element_list.py", line 72, in __getattr__
    return getattr(self.first, name)
AttributeError: 'WebDriverElement' object has no attribute 'send_keys'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dname/Downloads/pythoncrawling/requested1.py", line 53, in <module>
    span_tag.send_keys("hello this is example")
  File "/anaconda/lib/python3.5/site-packages/splinter/element_list.py", line 75, in __getattr__
    self.__class__.__name__, name))
AttributeError: 'ElementList' object has no attribute 'send_keys'
回溯(最近一次呼叫最后一次):
文件“/anaconda/lib/python3.5/site packages/splitter/element_list.py”,第72行,在__
返回getattr(self.first,name)
AttributeError:“WebDriveRelation”对象没有“发送密钥”属性
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/Users/dname/Downloads/pythoncrawling/requested1.py”,第53行,在
span_tag.send_key(“你好,这是示例”)
文件“/anaconda/lib/python3.5/site packages/splitter/element_list.py”,第75行,在__
self.\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
AttributeError:“ElementList”对象没有属性“发送密钥”

Splinter看起来还处于开发的早期阶段,并没有您期望从普通selenium python API(包括send_键)获得的所有API。如果我是你的话,我会扔掉斯普林特,只使用普通的绑定


此处未提及send_键或其他对象的任何其他API。

Splinter看起来还处于开发阶段,并没有您期望从普通selenium python API(包括send_键)获得的所有API。如果我是你的话,我会扔掉斯普林特,只使用普通的绑定

span_tag.first._element.send_keys(...)

此处未提及send_键或其他对象的任何其他API

span_tag.first._element.send_keys(...)
参考内部硒元素

参考内部硒元素