1

I wrote the code according to google, I downloaded operadriver, I showed it as the path, but I am getting this error. what am i doing wrong here?

[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'

this is my code.

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)`

i don't understand where i went wrong. I just changed the path part with google to open it in opera. I don't get a problem when I run it with chromedriver

eymentakak
  • 43
  • 5
  • To solve problems like this, I would start by adding `print(eMail)` to see its value. Read [this article](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) for tips on debugging similar issues. – Code-Apprentice Jan 18 '22 at 20:18

2 Answers2

0

The solution to the problem is simple, all you have to do is download the old version of Selenium:

pip install selenium==3.141.0
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
eymentakak
  • 43
  • 5
0

This error message...

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

...was a known issue with Selenium


As @AutomatedTester suggested there are two pottential solutions:

  • Upgrading to the latest opera/chrome will make this work.
  • Setting w3c:true in goog:chromeOptions will make things work properly.

Example chrome setting:

options = webdriver.ChromeOptions()
options.w3c = True
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352