When I use selenium in python to open a website in chrome it give me an Attribute Error This is my code :
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
browser = webdriver.Chrome(ChromeDriverManager().install())
browser.get('https://google.com')
And it give me this error :
AttributeError: 'str' object has no attribute 'capabilities'
I am expecting to open the chrome in google. And I tried to uninstall the modules and reinstall the modules one more time and tried to download the driver manually put in the option attribute but didn't work.
You should use
playwrightinstead, as it is a much newer python library and has many advantages overselenium.Installation:
pip install playwright, followed by:playwright install, and webkit, firefox, and chromium will be downloaded. Don't worry, you can still use chrome and msedge. Snippet of code:Since you're using chrome, you want to add the channel argument like I have, but keep the chromium part. (Just copy my code and it should work). I showed as an example just a few of the functions the
playwrightlibrary has. Note thatplaywrightlaunches in headless mode by default, so you'll need to add an argument if you want to be able to see the browser launching.The reason I suggest you use
playwrightinstead ofseleniumis thatplaywrightdoes not require a webdriver, and it is a much newer and up to date python library, and it has many more applications and features. This will also solve yourAttributeError.