Вот часть HTML: nullnullnullnullnullnullnullnull Закон о защите растений и Гигиена "itemTemplate":"\u003cspan class="#: (checkIfValidStateAndNotCurrentRegulation(data)) ? \u0027\u0027: \u0027k-state-disabled\u0027#"\u003e#: data.OfficialTitle #\u003c/span\u003e", "фильтр":"содержит","анимация":false,"значение":[]});});
Вот мой код:
из playwright.sync_api import sync_playwright
def select_amendment(amendment_title):
с sync_playwright() как p:
Код: Выделить всё
browser = p.chromium.launch(headless=False) # Set headless=True for background execution
context = browser.new_context()
page = context.new_page()
# Replace with the actual URL of your webpage containing the Kendo UI MultiSelect
page.goto("https://your-website.com")
# Wait for the Kendo UI MultiSelect element with the specified ID
page.wait_for_selector("#AmendedRegulations")
# Get the Kendo UI MultiSelect element
multiselect_element = page.query_selector("#AmendedRegulations")
# Open the dropdown
multiselect_element.click()
# Select the option by title using CSS selector (adjust based on your HTML structure)
option_to_select = page.query_selector(f"span.k-item-text:contains('{amendment_title}')")
option_to_select.click()
# Wait for the dropdown to close (optional)
# page.wait_for_selector(".k-list.k-reset", hidden=True) # Adjust selector if necessary
# Close the browser
browser.close()
select_amendment("Закон о безопасности пищевых продуктов
")< /п>
Подробнее здесь: https://stackoverflow.com/questions/786 ... right-test