Select an element inside a p-dropdown tag using Selenium and Python

Solution for Select an element inside a p-dropdown tag using Selenium and Python
is Given Below:

I am trying to select the 200 option on a p-dropdown using Selenium and Python with this function getting a timeout exception with no message…

Selection = Select(WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[contains(@class,'ui-dropdown-') and @aria-label="200"]"))))
Selection.select_by_value("200")

the dropdown menu looks like this:

<div class="ui-dropdown-items-wrapper" style="max-height: 200px;">
    <ul class="ui-dropdown-items ui-dropdown-list ui-widget-content ui-widget ui-corner-all ui-helper-reset" role="listbox">
        <p-dropdownitem class="ng-tns-c10-0 ng-star-inserted" style="">
            <li role="option" class="ui-dropdown-item ui-corner-all ui-state-highlight" aria-label="25">
                <span class="ng-star-inserted">25</span>
            </li>
        </p-dropdownitem>
        <p-dropdownitem class="ng-tns-c10-0 ng-star-inserted" style="">
            <li role="option" class="ui-dropdown-item ui-corner-all" aria-label="50">
                <span class="ng-star-inserted">50</span>
            </li>
        </p-dropdownitem>
        <p-dropdownitem class="ng-tns-c10-0 ng-star-inserted" style="">
            <li role="option" class="ui-dropdown-item ui-corner-all" aria-label="100">
                <span class="ng-star-inserted">100</span>
            </li>
        </p-dropdownitem>
        <p-dropdownitem class="ng-tns-c10-0 ng-star-inserted" style="">
            <li role="option" class="ui-dropdown-item ui-corner-all" aria-label="200">
                <span class="ng-star-inserted">200</span>
            </li>
        </p-dropdownitem>
    </ul>
</div>

Anyone knows or can throw me a bone on how can I select the 200 option to show all the registers in just one page and avoid the initial pagination?

thanks in advance.

Select() works if the elements are in a select tag.

Collect the p elements and iterate for the right option.

    options = driver.find_elements_by_xpath(".../p")
    for o in options:
    ...

Or click on the drop down and click on the required option.

This is not Select type if you pass this element to the Select it will throw the Exception UnexpectedTagNameException internally its constructor perform check is made that the given element is, indeed, a SELECT tag. If it is not, then an UnexpectedTagNameException is thrown.

Based on the provide HTML source if you can check with the below XPath

((//div[@class="ui-dropdown-items-wrapper"]//li)[4])

 element = driver.find_element_by_xpath("((//div[@class="ui-dropdown-items-wrapper"]//li)[4])")

print(element.get_attribute("aria-label")

you can enhance the code as per your requirement