Created
October 23, 2023 07:34
-
-
Save u1i/fe1e24fc392cb586798959c601157356 to your computer and use it in GitHub Desktop.
Selenium Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.chrome.service import Service | |
from selenium.webdriver.common.service import Service | |
# Replace with the URL of your Selenium Grid hub on localhost. | |
grid_hub_url = "http://localhost:4444/wd/hub" | |
# Set the Chrome browser options. | |
chrome_options = webdriver.ChromeOptions() | |
chrome_options.add_argument("--headless") # Example: Run Chrome in headless mode. | |
# Initialize the WebDriver with the grid hub URL and Chrome options. | |
driver = webdriver.Remote( | |
command_executor=grid_hub_url, | |
options=chrome_options | |
) | |
# Navigate to the website you want to crawl. | |
url = "https://www.sotong.io" # Replace with your target website. | |
driver.get(url) | |
# You can now interact with the web page using Selenium. | |
# For example, let's print the page title. | |
print("Page title: " + driver.title) | |
# When you're done, close the browser. | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment