Files
railseek6/find_selector.py
2026-01-12 22:31:11 +08:00

36 lines
1.4 KiB
Python

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=options)
driver.implicitly_wait(5)
wait = WebDriverWait(driver, 10)
try:
driver.get('http://localhost:3015')
time.sleep(3) # let page load
# Find all elements with class containing 'Select'
elements = driver.find_elements(By.CSS_SELECTOR, '[class*="Select"]')
for elem in elements:
print(elem.tag_name, elem.get_attribute('class'), elem.get_attribute('id'), elem.text[:50])
# Find button with role combobox
combos = driver.find_elements(By.CSS_SELECTOR, '[role="combobox"]')
for c in combos:
print('Combobox:', c.tag_name, c.get_attribute('class'), c.text[:50])
# Find any element with text 'workspace' (case insensitive)
workspaces = driver.find_elements(By.XPATH, "//*[contains(translate(text(), 'WORKSPACE', 'workspace'), 'workspace')]")
for w in workspaces:
print('Workspace text:', w.tag_name, w.get_attribute('class'), w.text[:50])
# Take screenshot
driver.save_screenshot('page.png')
print('Screenshot saved')
except Exception as e:
print('Error:', e)
finally:
driver.quit()