send_keys python selenium 的问题

问题描述

我正在尝试使用 python 和 selenium 制作一个小的 Facebook 群组自动发布脚本

首先,我使用以下代码上传 3/4 张照片:

l = driver.find_elements_by_tag_name('input')
for g in l:
    print(g)
    try:
        if g == driver.find_element_by_xpath("//input[@type='file']"):
            print("Found")
            logging.debug("Found input for image uploading")
            g.send_keys(
                '/var/www/html/v1/insta-post/AutopostFB/images/0.jpg \n/var/www/html/v1/insta-post/AutopostFB/images/1.jpg \n/var/www/html/v1/insta-post/AutopostFB/images/2.jpg')
            print("File/s Uploaded")
            logging.debug("Images uploaded")
            time.sleep(5)
            # break
    except:
        print("Element not found after upload")
        logging.debug("Element for upload not found")

然后我推送帖子文本,因为文本框已经在焦点上

actions = ActionChains(driver)
actions.send_keys(info)
actions.perform()
time.sleep(1)

问题是 info 变量中的每个空格都异常转换为返回键

所以如果文字

info = "HEI HOW'S IS GOING?"

我在文本框中得到的是

IS
GOING
hey
HOW'S

有人可以帮我吗?我什么都试过了

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...