【问题标题】:Trying to insert text into gmail's Search field尝试将文本插入 gmail 的搜索字段
【发布时间】:2019-07-03 07:47:17
【问题描述】:

我正在尝试使用 Selenium (python) 在 gmail.com 的搜索字段中插入文本,但遇到了一些问题。

我正在使用这个:

driver.find_element_by_xpath("(//input[starts-with(@role, 'search')])")

我希望找到可用于应用方法 send_keys() 的对象, 但得到错误:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"(//input[starts-with(@role, 'search')])"}

【问题讨论】:

    标签: python selenium gmail selenium-chromedriver


    【解决方案1】:

    试试:

    driver.find_element_by_name("q")
    

    我还要指出,尝试使用 Selenium 自动化 Gmail 是一个非常糟糕的主意。我建议改用 GMail 的 API 访问 - https://developers.google.com/gmail/api/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-04
      • 1970-01-01
      • 2017-03-01
      • 2015-01-12
      • 2020-07-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多