37 lines
1.2 KiB
Python
37 lines
1.2 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)
|
|
# Find combobox button
|
|
combobox = driver.find_element(By.CSS_SELECTOR, '[role="combobox"]')
|
|
print('Combobox outer HTML:', combobox.get_attribute('outerHTML'))
|
|
# Find parent
|
|
parent = combobox.find_element(By.XPATH, '..')
|
|
print('Parent outer HTML:', parent.get_attribute('outerHTML'))
|
|
# Find sibling that might be dropdown
|
|
# Click combobox to open dropdown
|
|
combobox.click()
|
|
time.sleep(1)
|
|
# Find dropdown content
|
|
dropdown = driver.find_element(By.CSS_SELECTOR, '[role="listbox"]')
|
|
print('Dropdown outer HTML:', dropdown.get_attribute('outerHTML'))
|
|
# List items
|
|
items = dropdown.find_elements(By.CSS_SELECTOR, '[role="option"]')
|
|
for i, item in enumerate(items):
|
|
print(f'Item {i}:', item.get_attribute('outerHTML'))
|
|
except Exception as e:
|
|
print('Error:', e)
|
|
import traceback
|
|
traceback.print_exc()
|
|
finally:
|
|
driver.quit() |