【问题标题】:I can't use opera with selenium我不能将歌剧与硒一起使用
【发布时间】:2022-01-18 18:58:12
【问题描述】:

我根据google写了代码,我下载了operadriver,我把它显示为路径,但是我得到了这个错误。我在这里做错了什么?

[9876:1776:0118/202302.637:ERROR:CONSOLE(0)] "Unchecked runtime.lastError: Could not establish     connection. Receiving end does not exist.", source: chrome://startpage/ (0)
[1332:1920:0118/202305.270:ERROR:ssl_client_socket_impl.cc(983)] handshake failed; returned     -1, SSL error code 1, net_error -100
C:\Users\test\Desktop\RandevuSpt\start.py:12: DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
  eMail =     site.find_element_by_xpath("-------------")
Traceback (most recent call last):
  File "C:\Users\test\Desktop\RandevuSpt\start.py", line 13, in <module>
    eMail.send_keys(cf.kullaniciadi)
AttributeError: 'dict' object has no attribute 'send_keys'

这是我的代码。

from selenium import webdriver
from time import sleep
import smtplib, ssl
import config as cf 

 

site = webdriver.Chrome(cf.ChromePath)
site.get("-------------")
sleep(1)

eMail = site.find_element_by_xpath("------------")
eMail.send_keys(cf.kullaniciadi)

sifre = site.find_element_by_xpath("-------------")
sifre.send_keys(cf.girissifre)
sleep(0.5)
butona_bas = site.find_element_by_css_selector("---------------")
butona_bas.click()
sleep(0.8)
giris_yap = site.find_element_by_css_selector("---------")
giris_yap.click()
sleep(1)
devamet = site.find_element_by_css_selector("----------------")
devamet.click()
sleep(1)
ode = site.find_element_by_css_selector("-------------")
ode.click()
sleep(1)
ode2 = site.find_element_by_xpath("---------------")
ode2.click()
sleep(1)

element = site.find_element_by_xpath("--------------")
print(element.text)

if "2022" in element.text:

    sleep(1)

    email_from = cf.gonderenmail
    password = cf.gonderensifre
    email_to = cf.alicimail

    emailstring = element.text

    context = ssl.create_default_context()
    with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:

        server.login(email_from, password)
        server.sendmail(email_from, email_to, emailstring)

sleep(60)
site.refresh()
sleep(1)`

我不明白我哪里出错了。 我只是用谷歌更改了路径部分以在歌剧中打开它。 当我使用 chromedriver 运行它时,我没有遇到问题

【问题讨论】:

  • 为了解决这样的问题,我会先添加print(eMail) 来看看它的价值。阅读this article 了解调试类似问题的技巧。

标签: python python-3.x selenium selenium-webdriver


【解决方案1】:

此错误消息...

AttributeError: 'dict' object has no attribute 'send_keys'

...是Selenium 的一个已知问题


作为@AutomatedTestersuggested,有两种可能的解决方案:

  • 升级到最新的opera/chrome 即可完成这项工作。
  • goog:chromeOptions 中设置 w3c:true 将使事情正常进行。

镀铬设置示例:

options = webdriver.ChromeOptions()
options.w3c = True

【讨论】:

    【解决方案2】:

    问题的解决方法很简单,只需要下载老版本的Selenium即可:

    pip install selenium==3.141.0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      相关资源
      最近更新 更多