'Selenium: Drop Down list with div tag instead of select tag

I am new to automated testing with Selenium Web Driver. I am not able to figure it how to test drop down lists of the location type without using the select command. I have div tag.

I was trying to send keys but did not work.

I am working on this website: https://freightpower.schneider.com (>>get a quote>>less than truckload) You may then need to register but it is very quick.enter image description here

enter image description here

 driver.find_elements(by=By.XPATH, value = '//div[@class="dropdownstyle__StyledValueContainer-sc-13n3p0k-2 dIpAqS"]')[0].click()

Then I need to choose one of the options but could not do it. Any help would be appreciated ! I know how I can choose if I could have select tag but now I do not have it and really do not know what to do although checking many related questions.

enter image description here



Solution 1:[1]

In my project, I am using selenium automated test. There is an selection box that includes hospital names and user choose hospitals. Maybe you can use find_element_by_id and find_elements_by_tag_name together like this:

try:
    el = driver.find_element_by_id('hospital_name')
    for option in el.find_elements_by_tag_name('option'):
        if option.text == 'Mount Sinai West':
            time.sleep(5)
            logging.info("Hospital name was added")
            option.click()
            break
except Exception as e:
    logging.exception(e)
    raise e

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 uozcan12