Chromedriver Manager with Python

Sachin Joshi
2 min readMay 11, 2022

--

In this article, I am going to cover how will you use chromedriver manager with python for your selenium scripts.

Pre-requisites

you need to install python3 on your machine to get started.

If you are using MacOS or Windows, I have already written an article on how to install Python

Imports

you need to import 2 required libraries using below 2 syntax.

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

Also, you need below 2 imports,

import time
import unittest

Create a class

you need to create a class using the unittest parameter as -

class mytest(unittest.TestCase):

Create a method

since you cannot write the code directly into the class. you need to create a method.

def testbasic(self):

Install chromedriver using chromedrivermanager

use below line of code to install chromedriver with the help of chromedrivermanage

self = webdriver.Chrome(ChromeDriverManager().install())

navigate to url

navigate to the URL.

self.get("https://www.amazon.in/")

replace the targeted url. here, I am using amazon.in

print the title to check url is opened

print(self.title)

quit the browser & driver instance

self.quit()

Here is the entire class file. you can try running by your own,

(make sure you will copy the code as it is, to avoid the space related syntax errors in python)

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

import time
import unittest


class mytest(unittest.TestCase):

def testbasic(self):

self = webdriver.Chrome(ChromeDriverManager().install())
self.implicitly_wait(5)
self.get("https://www.amazon.in/")
print(self.title)
time.sleep(5)
print("hello this is pass")
self.quit()

Hope this will get you going with python. I will be posting more articles on python testing, if you dont want to miss it then hit on follow button so that as soon as I post the article you will get an update.

Keep Reading, Keep Learning !!!

hit the follow button for more topics on Java, RestAssured, GraphQL, Selenium, JavaScript, JUnit, Jenkins, GitHub Actions, WebUI, SOAP & VBScripts

https://medium.com/@sachinjoshi12687

Also, DM me if you want me to add new topic of your choice urgently.

--

--

Sachin Joshi

follow me for more topics on Java, RestAssured, GraphQL, Selenium, JavaScript, JUnit, Jenkins, GitHub Actions, WebUI, SOAP & VBScripts