4

我正在将 EdgeDriver 与 Selenium 和 Python 3 一起使用

我已经能够通过手动创建js文件夹来修复它,但是 EdgeDriver 窗口没有加载页面,它显示Data;,在地址栏中。这些可能与不相关的错误有关。但是scoped_dir13788_764300980重新启动 cmd 提示符时的变化。

精简代码如下:

# importing required package of webdriver
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from time import sleep
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.opera.options import Options
from selenium.webdriver.support.wait import WebDriverWait

import schedule
import time
from random import randint


def job():
    while True:
        # Instantiate the webdriver with the executable location of MS Edge
        browser = webdriver.Edge(r"C:\Users\*****\Desktop\msedgedriver.exe")
        sleep(2)
        browser.maximize_window()
        sleep(2)
        browser.get('https://********/) #masked the name of website on purpose
        try:
            # Get the text box to insert Email using selector ID
            myElem_1 = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, 'anti-myhub')))
                        
            sleep(3)
            # Entering the email address
            myElem_1.click()

完整的错误是(屏蔽了 IP 和用户名):

[20444:17192:0308/100926.524:ERROR:storage_reserve.cc(164)] Failed to open file to mark as storage reserve: C:\Users\*****\AppData\Local\Temp\scoped_dir13788_764300980\Default\Code Cache\js

DevTools listening on ws://127.0.0.1:59454/devtools/browser/416f15a9-5a69-4025-9322-003aa9672acc
Traceback (most recent call last):
  File "check.py", line 79, in <module>
    job()
  File "check.py", line 21, in job
    browser = webdriver.Edge(r"C:\Users\******\Desktop\msedgedriver.exe")
  File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\edge\webdriver.py", line 66, in __init__
    desired_capabilities=capabilities)
  File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from tab crashed
  (Session info: MicrosoftEdge=**.**.**.**)
4

1 回答 1

0

我尝试将 msedge exe 放入 rool 文件夹中,并将路径指定为“executable_path = '.\msedgedriver.exe'”。

于 2021-05-08T04:58:23.267 回答