如何使用 selenium python 写消息

How to write a message using selenium python

我想知道如何在 linkedin 上写消息来发送我的连接。我已经使用发送键,但它只写了一行我也使用了 Keys.Shift + keys.enter 但它只能写两行。有什么方法可以使用硒在多行中编写完整的消息..写一个新行它也不起作用 "\n"

请告诉我有什么办法....

我试过下面的代码:-

description = browser.find_element_by_id("compose-message") 
description .send_keys('Hi' , Keys.SHIFT + Keys.ENTER, 'How are you')       
description .send_keys('Hi' "\n" 'How are you "\n" it is me') 

写多行都行不通

这对我有用...

description = browser.find_element_by_id("compose-message")
description.send_keys("Hi\nHow are you\n it is me")

我不确定页面是什么样子,上面有错字,您在描述和 send_keys 之间有一个 space,例如

description .send_keys('')

应该是

description.send_keys('') 

我也不明白你为什么要用shift enter(也许是加一个新行?)如果是这样你试过了吗

description.send_keys('Hi,\nHow are you') 

其中 '\n' 是换行符

只需要取消选中消息框中的 "press enter to send" 什么都不用做。最后一件事是。发送长消息时它在 Firefox 上不起作用只需使用 Chrome webdriver