# Import the necessary packages from selenium import webdriver # Launch the Chrome browser driver = webdriver.Chrome() # Navigate to the website to search driver.get('https://www.google.com') # Find the search input box and enter a keyword search_input = driver.find_element_by_tag_name('input') search_input.send_keys('Python Selenium') # Click the search button search_button = driver.find_element_by_tag_name('button') search_button.click() # Close the browser driver.quit()
# Import the necessary packages from selenium import webdriver # Launch the Firefox browser driver = webdriver.Firefox() # Navigate to a website driver.get('https://www.w3schools.com') # Find all the links on the page links = driver.find_elements_by_tag_name('a') # Print the number of links found print(len(links)) # Click on the first link links[0].click() # Close the browser driver.quit()In this example, we use find_elements_by_tag_name() to locate all the links on the W3Schools website. We then print the number of links found and click on the first link. The package library used in these examples is Selenium WebDriver.