Мне нужен способ справиться с ошибкой SSL-сертификата в моем коде: Это трассировка:
[29756:38612:0402/135226.106:ERROR:ssl_client_socket_impl.cc(941)] handshake failed; returned -1, SSL error code 1, net_error -208
[29756:38612:0402/135226.112:ERROR:ssl_client_socket_impl.cc(941)] handshake failed; returned -1, SSL error code 1, net_error -208
Traceback (most recent call last):
File ".\remove_sec_groups_inactive_users.py", line 104, in <module>
element = WebDriverWait(browser, 20).until(
File "C:\Python38\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Сейчас я могу получить это, но хотел бы зафиксировать ошибки SSL на страница из-за отсутствия сертификата SSL. Кроме того, возникает другая проблема, связанная с сообщениями о сбое рукопожатия для TCP:
PS C:\Users\richard.barrett\Git\ITDataServicesInfra\Python\Skyward\Reports> [6228:20372:0403/143125.317:ERROR:ssl_client_socket_impl.cc(941)] handshake failed; returned -1, SSL error code 1, net_error -208
[6228:20372:0403/143355.329:ERROR:ssl_client_socket_impl.cc(941)] handshake failed; returned -1, SSL error code 1, net_error -208
. Это все по большей части элементы, которые мне нужны для захвата, и предлагают предупреждение v. Загромождают мой экран.
У меня также есть другая трассировка, в которой конкретный предмет не кликабелен. Я пытаюсь нажать на экспорт загрузки, нажав на кнопку, которая выглядит следующим образом:
Отслеживание:
File ".\export_secured_users_list_report.py", line 161, in <module>
element.click();
File "C:\Python38\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Python38\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <a id="browsetool_export" class="toolLink openText" alt="Export Options" tooltip="Export Options" tooltip-position="top" onmouseout="getMenu('export',this).hide();" onmouseover="getMenu('export',this).keepOpen();" href="javascript:getMenu('export',this).toggle()" onclickx="fwSky.browse.exportExcel();" aria-labelledby="" style="">...</a> is not clickable at point (897, 140). Other element would receive the click: <div id="lockDiv" style="z-index: 100; position: absolute; left: 0px; top: 0px; height: 684px; width: 100%; visibility: visible; background-color: rgb(255, 255, 255); opacity: 0;" oncontextmenu="return false;"></div>
(Session info: chrome=80.0.3987.163)
Вот мой код: https://github.com/Richard-Barrett/ITDataServicesInfra/blob/master/Python/Skyward/Reports/export_secured_users_list_report.py
#!/bin/usr/env python
# ===========================================================
# Created By: Richard Barrett
# Organization: DVISD
# DepartmenT: Data Services
# Purpose: Skyward Reports
# Date: 04/03/2020
# ===========================================================
import selenium
import shutil
import xlsxwriter
import os
import unittest
import requests
import subprocess
import getpass
import platform
import socket
import ssl
import pynput
import logging
import time
from pynput.keyboard import Key, Controller
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from datetime import date
decrypt = "gpg --output secrets.json --decrypt secrets.gpg"
if os.path.exists("secrets.gpg"):
returned_value = subprocess.call(decrypt, shell=True)
else:
print("The file does not exist!")
print("You should probably create a secret!")
print("gpg --output filename.gpg --encrypt filename.json")
import json
with open('secrets.json','r') as f:
config = json.load(f)
# Definitions
# find_elements_by_name
# find_elements_by_xpath
# find_elements_by_link_text
# find_elements_by_partial_link_text
# find_elements_by_tag_name
# find_elements_by_class_name
# find_elements_by_css_selector
# System Variables
today = date.today()
date = today.strftime("%m/%d/%Y")
node = platform.node()
system = platform.system()
username = getpass.getuser()
version = platform.version()
keyboard = Controller()
# Upload Path Variables
file_input_inactive_users = os.path.abspath("<insert_file_path>")
# URL Variables
login_url = ''
redirect_url = ''
reports_scheduler_url = ''
custom_reports_url = ''
# Check for Version of Chrome
# WebDriver Path for OS.System
if platform.system() == ('Windows'):
browser = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\chromedriver.exe")
elif platform.system() == ('Linux'):
browser = webdriver.Chrome(executable_path='/home/rbarrett/Drivers/Google/Chrome/chromedriver_linux64/chromedriver')
elif platform.system() == ('Darwin'):
browser = webdriver.Chrome(executable_path='~/Drivers/Google/Chrome/chromedriver_mac64/chromedriver')
else:
print("Are you sure you have the Selenium Webdriver installed in the correct path?")
# TearDown Method
def tearDown(self):
self.browser.close()
# ShutDown Method
def shutDown(self):
self.browser.quit()
# Parent URL
#browser.get(config['URL']['target_url'])
#browser.get("https://skyward-student.del-valle.k12.tx.us/scripts/wsisa.dll/WService=wsEAplus/seplog01.w?nopopup=true")
#options.addArguments("--ignore-certificate-errors")
browser.get("https://skyward-dev.del-valle.k12.tx.us/scripts/wsisa.dll/WService=wsEAplusTrn/seplog01.w?nopopup=true")
time.sleep(5)
# Click on Advanced Button for Certificate Error
# XPATH //*[@id='details-button']
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='details-button']")))
element.click();
# Click on Proceed
# XPATH //*[@id'proceed-link']
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.ID, "proceed-link")))
element.click();
time.sleep(10)
# Credentials NEEDS UNIT TEST
username = browser.find_element_by_id("login")
password = browser.find_element_by_id("password")
username.send_keys(config['user']['name'])
password.send_keys(config['user']['password'])
# Authentication submit.click()
# For XPATH = //*[@id='bLogin']
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='bLogin']")))
element.click();
print("Logging into Skyward!")
print("Authenticated")
# Click and Span Skyward Contact Access
# Adminsitration XPATH = //*[@id='nav_ContactAccess']/span
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='nav_ContactAccess']/span")))
element.click();
# Click on Secured Users Access
# Adminsitration XPATH = //*[@id='nav_SecuredUserSuperUser']/span
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='nav_SecuredUserSuperUser']/span")))
element.click();
# Click on id="browsetool_export"
# Opens Options to Download Report
# XPATH = //*[@id='browsetool_export']
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='browsetool_export']")))
element.click();
# Click on .CSV Radio Button
# XPATH = //*[@id='ExCOptCSV']
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='ExCOptCSV']")))
element.click();
# Click on Export Button
# XPATH = //*[@id='bExport']
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='bExport']")))
element.click();
# Click on id="browsetool_export"
# Opens Options to Download Report
# XPATH = //*[@id='browsetool_export']
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='browsetool_export']")))
element.click();
# Click on .xlsx Radio Button
# XPATH = //*[@id='ExCOptXLSX']
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='ExCOptXLSX']")))
element.click();
# Click on Export Button
# XPATH = //*[@id='bExport']
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='bExport']")))
element.click();
time.sleep(20)
# Click on Download Export Button
# XPATH = //*[@id='printMsgBtn1']
element = WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='printMsgBtn1']")))
element.click();
# Click on Run Button
# Run Button XPATH =
# Delete Unencrypted JSON File
if os.path.exists("secrets.json"):
os.remove("secrets.json")
print("The file was removed and everything is clean!")
else:
print("The file does not exist")
# Close Browser Session Gracefully
print("The Export was successfull!")
#browser.quit()