31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from selenium import webdriver
|
|
from selenium.webdriver.common.by import By
|
|
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)
|
|
|
|
try:
|
|
driver.get('http://localhost:3015')
|
|
time.sleep(3)
|
|
combobox = driver.find_element(By.CSS_SELECTOR, '[role="combobox"].w-48')
|
|
combobox.click()
|
|
time.sleep(1)
|
|
dropdown = driver.find_element(By.CSS_SELECTOR, '[role="listbox"][data-state="open"]')
|
|
options = dropdown.find_elements(By.CSS_SELECTOR, '[role="option"]')
|
|
for i, opt in enumerate(options):
|
|
span = opt.find_element(By.CSS_SELECTOR, 'span')
|
|
print(f'Option {i}: span text="{span.text}"')
|
|
print(' id:', span.get_attribute('id'))
|
|
print(' class:', span.get_attribute('class'))
|
|
driver.save_screenshot('dropdown_options.png')
|
|
except Exception as e:
|
|
print('Error:', e)
|
|
import traceback
|
|
traceback.print_exc()
|
|
finally:
|
|
driver.quit() |