from selenium import webdriver driver = webdriver.Chrome() driver.get("https://www.google.com/") search_button = driver.find_element_by_xpath('//input[@name="btnK"]') search_button.click() driver.quit()
element = driver.find_element_by_xpath("//div[@class='class-name']")Here the `find_element_by_xpath()` method searches for the first `div` element with a `class` attribute containing the specified class name. This is a useful way to locate elements with predefined styles, such as buttons, inputs or sections. In both these examples, the package library used is `selenium`, which is a Python library providing a clean API to write web automation scripts, using a variety of browsers and injecting JavaScript code as needed to manipulate the DOM.