gpt4 book ai didi

python - Selenium 文件错误,我无法正确导入它们

转载 作者:行者123 更新时间:2023-12-03 08:16:42 24 4
gpt4 key购买 nike

我已经尝试了一切... stackoverflow是最终选择

    from selenium import *
from selenium import webdriver
import time

driver = webdriver.Firefox()
driver.maximize_window()
location = r"C:\Users\rehma\PycharmProjects\myProject\webpage.html"
driver.get(location)
单击“警报”按钮以生成简单警报
    button = driver.find_element_by_name('alert')
button.click()
将控件切换到“警报”窗口
    obj = driver.switch_to.alert
在“警报”窗口中检索消息
    msg = obj.text
print("Alert shows following message: "+ msg )

time.sleep(2)
使用accept()方法接受警报
    obj.accept()

print(" Clicked on the OK Button in the Alert Window")

driver.close
现在出现错误

Traceback (most recent call last):
File "C:\Users\rehma\PycharmProjects\myProject\testing.py", line 4, in <module>
from selenium import webdriver
File "C:\Users\rehma\PycharmProjects\myProject\venv\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "C:\Users\rehma\PycharmProjects\myProject\venv\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 29, in <module>
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
File "C:\Users\rehma\PycharmProjects\myProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 27, in <module>
from .remote_connection import RemoteConnection
File "C:\Users\rehma\PycharmProjects\myProject\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 24, in <module>
import urllib3
File "C:\Users\rehma\PycharmProjects\myProject\venv\lib\site-packages\urllib3\__init__.py", line 7, in <module>
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
File "C:\Users\rehma\PycharmProjects\myProject\venv\lib\site-packages\urllib3\connectionpool.py", line 11, in <module>
from .exceptions import (
File "C:\Users\rehma\PycharmProjects\myProject\venv\lib\site-packages\urllib3\exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
File "C:\Users\rehma\PycharmProjects\myProject\venv\lib\site-packages\urllib3\packages\six.py", line 199, in load_module
mod = mod._resolve()
File "C:\Users\rehma\PycharmProjects\myProject\venv\lib\site-packages\urllib3\packages\six.py", line 113, in _resolve
return _import_module(self.mod)
File "C:\Users\rehma\PycharmProjects\myProject\venv\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
File "C:\Users\rehma\Downloads\lib\http\client.py", line 71, in <module>
import email.parser
ModuleNotFoundError: No module named 'email.parser'; 'email' is not a package

最佳答案

您的文件可能命名为email.py,将其更改为其他名称。

关于python - Selenium 文件错误,我无法正确导入它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65831315/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com