简体   繁体   中英

In, selenium automation with python, for webdriver_manager.chrome and ChromeDriverManager

Hi I'm getting below error

**driver = webdriver.Chrome(ChromeDriverManager.install())

TypeError: install() missing 1 required positional argument: 'self'**

Process finished with exit code 1

and my code is

from selenium import webdriver
from selenium.webdriver.common.by import By
import time

from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager



browserName = 'chrome'
if browserName == 'chrome':
    driver = webdriver.Chrome(ChromeDriverManager.install())

elif browserName == 'firefox':
    driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())

elif browserName == 'safari':
    driver= webdriver.safari()
else :
    driver = webdriver.Edge(EdgeChromiumDriverManager().install())'''

you will need to instantiate the class before using it like the below:

p= ChromeDriverManager()
driver = webdriver.Chrome(executable_path=p.install())

similarly you can do the same for other browsers as well

refer: TypeError: Missing 1 required positional argument: 'self' for better understanding

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM