0

I have following problem: My script doesn't execute the code between problem-comments. This script should login into yandex-mail page (https://passport.yandex.ru/auth) find by xpath the search-field for mails, click on it and finally entering: subject:(Your Steam account: Access from new web or mobile device). And when the script comes to the point, where it must find the search-field, the programm shuts down.

Here is the code:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

driver = webdriver.Chrome()

driver.get('https://passport.yandex.ru/auth')

try:
    email_element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "passp-field-login"))
    )
    time.sleep(2)
    email_element.send_keys("LOGIN", Keys.RETURN)

    time.sleep(2)

    password_element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "passp-field-passwd"))
    )
    password_element.send_keys("PASSWORD", Keys.RETURN)

    #Wait for the inbox page to load before proceeding
    WebDriverWait(driver, 10).until(
        EC.title_contains("Inbox")
    )

    time.sleep(2)

    # problem starts here
    inbox_element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "//*[@id='js-apps-container']/div[2]/div[7]/div/div[1]/div/div/div[1]/div[2]/div/div/div/div[1]/form/div/span/input"))
    )
    inbox_element.send_keys("subject:(Your Steam account: Access from new web or mobile device)", Keys.RETURN)

    # problem occurs here
    # Do something with the inbox page
    # ...

except Exception as e:
    print(f'An error occurred: {e}')

finally:
    driver.quit()

I tried to execute the code but following errors come:

Errors before the problem tags:

[34024:23964:0301/191243.416:ERROR:ssl_client_socket_impl.cc(985)] handshake failed; returned -1, SSL error code 1, net_error -101
[7428:42888:0301/191245.636:ERROR:device_event_log_impl.cc(218)] [19:12:45.637] USB: usb_device_handle_win.cc:1046 Failed to read descriptor from node connection: Ein an das System angeschlossenes Gerõt funktioniert nicht. (0x1F)
[7428:42888:0301/191245.642:ERROR:device_event_log_impl.cc(218)] [19:12:45.642] USB: usb_device_handle_win.cc:1046 Failed to read descriptor from node connection: Ein an das System angeschlossenes Gerõt funktioniert nicht. (0x1F)

Errors after problem tags:

[34024:23964:0301/191254.717:ERROR:ssl_client_socket_impl.cc(985)] handshake failed; returned -1, SSL error code 1, net_error -101
[34024:23964:0301/191254.722:ERROR:ssl_client_socket_impl.cc(985)] handshake failed; returned -1, SSL error code 1, net_error -101 
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

0

This error message...

[34024:23964:0301/191243.416:ERROR:ssl_client_socket_impl.cc(985)] handshake failed; returned -1, SSL error code 1, net_error -101

...implies that the browser is asking you to accept the certificate from a website.


Solution

You can configure the ChromeDriver to ignore these errors by default adding the following arguments:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--ignore-certificate-errors')
options.add_experimental_option('--ignore-ssl-errors')
driver = webdriver.Chrome(options=options)
driver.get('https://passport.yandex.ru/auth')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Hi, thanks for the answer, but following error comes: File "c:\Users\Google.fish\Desktop\proj\selenium-test2.py", line 12, in options.add_experimental_option('--ignore-ssl-errors') TypeError: ChromiumOptions.add_experimental_option() missing 1 required positional argument: 'value' PS C:\Users\Google.fish> – Googlefish Mar 02 '23 at 20:05
0

In your below code, I think by mistake you have used ID locator instead of XPath.

inbox_element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "//*[@id='js-apps-container']/div[2]/div[7]/div/div[1]/div/div/div[1]/div[2]/div/div/div/div[1]/form/div/span/input")))

Change it to By.XPATH, as you are using XPath expression to locate the element.

Shawn
  • 4,064
  • 2
  • 11
  • 23