3

I am trying to Initialise the MSedge Browser and getting an error.

from selenium import webdriver
from selenium.webdriver.edge.service import Service
from webdriver_manager.microsoft import EdgeChromiumDriverManager

s=Service(EdgeChromiumDriverManager().install())
driver = webdriver.Edge(service=s)
driver.get('https://www.google.com')

Error Statement:

TypeError                                 Traceback (most recent call last)
<ipython-input-2-4e36192a99d3> in <module>
      3 from webdriver_manager.microsoft import EdgeChromiumDriverManager
      4 
----> 5 s=Service(EdgeChromiumDriverManager().install())
      6 driver = webdriver.Edge(service=s)
      7 driver.maximize_window()

~\Anaconda3\lib\site-packages\webdriver_manager\microsoft.py in __init__(self, version, os_type, path, name, url, latest_release_url, log_level, print_first_line, cache_valid_range)
     49         cache_valid_range=1,
     50     ):
---> 51         super().__init__(path, log_level, print_first_line, cache_valid_range)
     52         self.driver = EdgeChromiumDriver(
     53             version=version,

~\Anaconda3\lib\site-packages\webdriver_manager\manager.py in __init__(self, root_dir, log_level, print_first_line, cache_valid_range)
     10         self.driver_cache = DriverCache(root_dir, cache_valid_range)
     11         if os.environ.get('WDM_PRINT_FIRST_LINE', str(print_first_line)) == 'True':
---> 12             log("\n", formatter='%(message)s', level=log_level)
     13         log("====== WebDriver manager ======", level=log_level)
     14 

~\Anaconda3\lib\site-packages\webdriver_manager\logger.py in log(text, level, name, first_line, formatter)
     23 def log(text, level=logging.INFO, name="WDM", first_line=False, formatter='[%(name)s] - %(message)s'):
     24     """Emitting the log message."""
---> 25     _init_logger(level, name, first_line, formatter)
     26     loggers.get(name).info(text)

~\Anaconda3\lib\site-packages\webdriver_manager\logger.py in _init_logger(level, name, first_line, formatter)
     17         handler.setFormatter(formatter)
     18         _logger.addHandler(handler)
---> 19         _logger.setLevel(level)
     20         loggers[name] = _logger
     21 

~\Anaconda3\lib\logging\__init__.py in setLevel(self, level)
   1407         Set the logging level of this logger.  level must be an int or a str.
   1408         """
-> 1409         self.level = _checkLevel(level)
   1410         self.manager._clear_cache()
   1411 

~\Anaconda3\lib\logging\__init__.py in _checkLevel(level)
    195         rv = _nameToLevel[level]
    196     else:
--> 197         raise TypeError("Level not an integer or a valid string: %r" % level)
    198     return rv
    199 

TypeError: Level not an integer or a valid string: None

I'm using webdriver_manager 3.5.2 and selenium 4.0.0 Please help me in resolving the issue. Let me know if you need any details. Thank you in advance

1 Answers1

4

That's an issue with webdriver_manager 3.5.2. It's a problem with the logger of webdriver_manager. For more information, you can refer to this issue and this pull request.

You can fix the issue by editing the source code of webdriver_manager according to the pull request. You can edit webdriver_manager/microsoft.py file, adding import logging and change log_level=None to log_level=logging.INFO. Then it can work well with Edge driver.

Yu Zhou
  • 11,532
  • 1
  • 8
  • 22
  • Thank you @Yu Zhou, I've seen the [same question](https://stackoverflow.com/questions/70240234/python-webdrivermanager-install-does-not-work-for-edge-in-custom-webdriver-in) raised by you. I have referred to that solution and it worked. I've changed the script in `Lib\site-packages\webdriver_manager\microsoft.py`. – Charan Supraj Baru Dec 28 '21 at 06:04
  • Thank you both @CharanSuprajBaru and Yu Zhou. Additionally, I encountered a strange problem. While debugging in VSC 1.63.2 everything worked fine. However, during normal execution I got `TypeError: Level not an integer or a valid string: None`. Do you have any idea why? I use Python 3.10.1 64-bit. – Soren V. Raben Dec 28 '21 at 14:34
  • @konard, it might be some problem with the imports. The update in microsoft.py might not be recognised i.e VSC is taking the already imported modules from cache. Or, the python interpreter you are using in debugging session is different from execution. – Charan Supraj Baru Dec 29 '21 at 16:29