this is a sample program using selenium to click a button:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import time
# Set up Chrome options
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless") # Run in headless mode (no UI)
chrome_options.add_argument("--disable-gpu") # Disable GPU acceleration for headless mode
chrome_options.add_argument("--no-sandbox") # Disable sandboxing for headless mode
chrome_options.add_argument("--disable-dev-shm-usage") # Fix shared memory issues
# Set up ChromeDriver using Service (Selenium 4)
service = Service(ChromeDriverManager().install())
# Initialize WebDriver (Chrome) with the path to your ChromeDriver
driver = webdriver.Chrome(service=service, options=chrome_options)
try:
# Open the website
driver.get("http://omsprodapp:9900/oms/f#ListedWrapper")
# Wait for the page to load (you might need to adjust this)
time.sleep(5)
# Find the "Blotter All" button by its ID and click it
blotter_button = driver.find_element(By.ID, "blotAllButt")
blotter_button.click()
# Wait for the action to complete (adjust the sleep if needed)
time.sleep(2)
print("Successfully clicked 'Blotter All'!")
finally:
# Close the browser after the task is completed
driver.quit()
No comments:
Post a Comment