In this article, I am going to cover how will you use chromedriver manager with python for your selenium scripts.
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
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 -
Create a method
since you cannot write the code directly into the class. you need to create a method.
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.
replace the targeted url. here, I am using amazon.in
print the title to check url is opened
quit the browser & driver instance
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 !!!