Skip to content

Instantly share code, notes, and snippets.

@u1i
Created October 23, 2023 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save u1i/fe1e24fc392cb586798959c601157356 to your computer and use it in GitHub Desktop.
Save u1i/fe1e24fc392cb586798959c601157356 to your computer and use it in GitHub Desktop.
Selenium Test
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