如何使用python填充输入文本字段? [英] How to fill input textfield using python?
问题描述
编辑 Firefor驱动程序中有一个错误.通过使用chrome驱动程序解决了该问题.
EDIT There was a bug in Firefor driver. It was solved by using chrome driver.
我是python的新手,我正在开发一个脚本,该脚本将使用webwhatsapp在whatsapp上发送消息. 但是我无法使用driver.send_key('message')方法在文本输入法中编写任何内容.
I am new to python and I am developing a script that will send message on whatsapp using webwhatsapp. But I am not able to write anything in text inputfeild using driver.send_key('message') method.
<input type="text" class="input input-search" data-tab="2" dir="auto" spellcheck="false" title="Search or start new chat" value="">
CODE
contactSearch=driver.find_element_by_xpath('//*[@title="Search or start new chat"]').click()
contactSearch.send_keys("name")
我也尝试了contactSearch.clear()和click()方法,但是输入仍然为空.代码来自 https://web.whatsapp.com/进行登录,然后会出现一个名为搜索"或开始新聊天的字段.我想在该字段中输入文本.
I have tried contactSearch.clear() and click() method also but the input remains blank.the code is from https://web.whatsapp.com/ go there login and there will be a feild called Search or start new chat.I want to input text in that field.
推荐答案
您尚未登录到硒会话中的whatsapp,因此没有新建聊天"按钮.默认情况下,Selenium会使用默认首选项,没有浏览器历史记录或Cookie来启动全新的浏览器会话.
You are not logged in to whatsapp in your selenium session and hence there is no "New chat" button. By default, selenium starts a brand new browser session with default preferences, no browser history or cookies.
这篇关于如何使用python填充输入文本字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!