Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
421 views
in Technique[技术] by (71.8m points)

python - Selenium files error, i'm not able to import them correctly

i have tried everything...stackoverflow is the final option

    from selenium import *
    from selenium import webdriver
    import time
    
    driver = webdriver.Firefox()
    driver.maximize_window()
    location = r"C:Users
ehmaPycharmProjectsmyProjectwebpage.html"
    driver.get(location)

Clicking on the "Alert" button to generate the Simple Alert

    button = driver.find_element_by_name('alert')
    button.click()

Switching the control to the Alert window

    obj = driver.switch_to.alert

Retrieving the message on the Alert window

    msg = obj.text
    print("Alert shows following message: "+ msg )
    
    time.sleep(2)

using the accept() method to accept the alert

    obj.accept()
    
    print(" Clicked on the OK Button in the Alert Window")
    
    driver.close

Now heres the error


    Traceback (most recent call last):
      File "C:Users
ehmaPycharmProjectsmyProjectesting.py", line 4, in <module>
        from selenium import webdriver
      File "C:Users
ehmaPycharmProjectsmyProjectvenvlibsite-packagesseleniumwebdriver\__init__.py", line 18, in <module>
        from .firefox.webdriver import WebDriver as Firefox  # noqa
      File "C:Users
ehmaPycharmProjectsmyProjectvenvlibsite-packagesseleniumwebdriverfirefoxwebdriver.py", line 29, in <module>
        from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
      File "C:Users
ehmaPycharmProjectsmyProjectvenvlibsite-packagesseleniumwebdriver
emotewebdriver.py", line 27, in <module>
        from .remote_connection import RemoteConnection
      File "C:Users
ehmaPycharmProjectsmyProjectvenvlibsite-packagesseleniumwebdriver
emote
emote_connection.py", line 24, in <module>
        import urllib3
      File "C:Users
ehmaPycharmProjectsmyProjectvenvlibsite-packagesurllib3\__init__.py", line 7, in <module>
        from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
      File "C:Users
ehmaPycharmProjectsmyProjectvenvlibsite-packagesurllib3connectionpool.py", line 11, in <module>
        from .exceptions import (
      File "C:Users
ehmaPycharmProjectsmyProjectvenvlibsite-packagesurllib3exceptions.py", line 2, in <module>
        from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
      File "C:Users
ehmaPycharmProjectsmyProjectvenvlibsite-packagesurllib3packagessix.py", line 199, in load_module
        mod = mod._resolve()
      File "C:Users
ehmaPycharmProjectsmyProjectvenvlibsite-packagesurllib3packagessix.py", line 113, in _resolve
        return _import_module(self.mod)
      File "C:Users
ehmaPycharmProjectsmyProjectvenvlibsite-packagesurllib3packagessix.py", line 82, in _import_module
        __import__(name)
      File "C:Users
ehmaDownloadslibhttpclient.py", line 71, in <module>
        import email.parser
    ModuleNotFoundError: No module named 'email.parser'; 'email' is not a package

question from:https://stackoverflow.com/questions/65831315/selenium-files-error-im-not-able-to-import-them-correctly

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...