我根據谷歌寫了代碼,我下載了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 運行它時,我沒有遇到問題
uj5u.com熱心網友回復:
此錯誤訊息...
AttributeError: 'dict' object has no attribute 'send_keys'
...是Selenium的一個已知問題
正如所@AutomatedTester 建議的,有兩種可能的解決方案:
- 升級到最新的opera/chrome 將使這項作業。
- 設定將使事情正常作業
w3c:true。goog:chromeOptions
鍍鉻設定示例:
options = webdriver.ChromeOptions()
options.w3c = True
uj5u.com熱心網友回復:
解決問題的方法很簡單,只需要下載舊版本的 Selenium:
pip install selenium==3.141.0
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/414613.html
標籤:
上一篇:使用POSIX實用程式或GNUcoreutils或Perl計算尾隨換行符
下一篇:Selenium無法定位類元素
