from selenium import webdriver # Creating instance of Firefox webdriver driver = webdriver.Firefox(executable_path="C:\\geckodriver.exe") # Accessing website driver.get("https://www.google.com") # Closing current window driver.close()
from selenium import webdriver # Creating instance of Chrome webdriver driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") # Accessing website driver.get("https://www.youtube.com") # Waiting for 5 seconds driver.implicitly_wait(5) # Closing current window driver.close()This example is similar to the first, but we are using the Chrome webdriver instead of the Firefox webdriver. Additionally, we used the ".implicitly_wait()" method to wait for 5 seconds before closing the window. The package library used in these examples is Python Selenium.