Here’s a sample Selenium code that opens Google using Python:
from selenium import webdriver # Assuming you have a web driver instance, such as ChromeDriver driver = webdriver.Chrome() # Open Google driver.get("https://www.google.com") # Close the browser driver.quit()
In this example, we’re using the ChromeDriver as the web driver instance. You’ll need to have the ChromeDriver executable available in your system and properly configured.
Make sure you have the Selenium library installed (pip install selenium) and the ChromeDriver executable in your system’s PATH or provide the path to the executable by specifying the executable_path parameter in the webdriver.Chrome() constructor.
Once you run this code, it will open the Google homepage in a new Chrome browser window controlled by Selenium. After that, the driver.quit() method is called to close the browser.
Feel free to modify or enhance this code as per your requirements.