40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
from selenium import webdriver
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.common.keys import Keys
|
|
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('Current workspace:', combobox.text)
|
|
# Click to open dropdown
|
|
combobox.click()
|
|
time.sleep(1)
|
|
# Find the command input inside dropdown
|
|
cmd_input = driver.find_element(By.CSS_SELECTOR, '[cmdk-input]')
|
|
print('Command input found:', cmd_input.get_attribute('outerHTML'))
|
|
# Type something
|
|
cmd_input.send_keys('test')
|
|
time.sleep(1)
|
|
# Get dropdown items again
|
|
items = driver.find_elements(By.CSS_SELECTOR, '[role="option"]')
|
|
print(f'Number of options: {len(items)}')
|
|
for i, item in enumerate(items):
|
|
print(f'Option {i}:', item.text, item.get_attribute('outerHTML'))
|
|
# Take screenshot
|
|
driver.save_screenshot('dropdown.png')
|
|
except Exception as e:
|
|
print('Error:', e)
|
|
import traceback
|
|
traceback.print_exc()
|
|
finally:
|
|
driver.quit() |