I’m getting the error:
ModuleNotFoundError: No module named ‘webdriver_manager.Edge’. My Code is:
from selenium import webdriver
from selenium.webdriver.edge.options import Options
from selenium.webdriver.edge.service import Service
from webdriver_manager.Edge import ChromeDriverManager
def Mok():
chrome_options = Options()
chrome_options.add_argument("--headless")
driver=webdriver.Edge(options=chrome_options, service=Service(EdgeDriverManager().install()))
start_url='netlify.com'
driver.get(start_url)
print(driver.page_source.encode("utf-8"))
driver.get_screenshot_as_png('reddit.png')
print(driver.title)
driver.close()
Mok()
CodePudding user response:
import
from webdriver_manager.microsoft import EdgeChromiumDriverManager
[...]
driver = webdriver.Edge(EdgeChromiumDriverManager().install())
CodePudding user response:
You basically have a typo in your code:
See https://github.com/SergeyPirogov/webdriver_manager#use-with-edge
If you are using webdriver_manager
as your package.
Use with Edge:
# selenium 3
from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager
driver = webdriver.Edge(EdgeChromiumDriverManager().install())
# selenium 4
from selenium import webdriver
from selenium.webdriver.edge.service import Service as EdgeService
from webdriver_manager.microsoft import EdgeChromiumDriverManager
driver = webdriver.Edge(service=EdgeService(EdgeChromiumDriverManager().install()))
CodePudding user response:
In python, we need to install or we need to have access the module before importing it if the module is user-defined.
The error "ModuleNotFoundError: No module named 'webdriver_manager'" also implies that we didn't install the webdriver-manager module or we are importing it or installing it in an incorrect environment. To fix this error, install the module in the appropriate working directory or in a virtual environment by running the command.
pip install webdriver-manager