0

I want to autofill dropdown input

ex:

dropdown List

.css:

<input class="ui-dropdown-filter ui-inputtext ui-widget ui-state-default ui-corner-all" autocomplete="off" type="text">

</div><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">

<li class="ng-tns-c1-0 ui-dropdown-item ui-corner-all ng-star-inserted" style=""><!----><span class="ng-tns-c1-0 ng-star-inserted">Alabma</span><!----></li>

<li class="ng-tns-c1-0 ui-dropdown-item ui-corner-all ng-star-inserted" style=""><!----><span class="ng-tns-c1-0 ng-star-inserted">Alaska</span><!----></li>

</ul>

I tried:

 elementt = driver.find_element_by_css_selector(".ui-dropdown")
 driver.execute_script("arguments[0].click();", elementt)

 select = Select(driver.find_element_by_class_name('input.ui-dropdown-filter.ui-inputtext.ui-widget.ui-state-default.ui-cornee-all'))

 select.select_by_visible_text("Alaska")

But Nothing happen, any kind of help please?

2
  • 2
    To use Select class, the element in DOM should in be in a select tag. You need to click on the dropdown element, find the option and click on that. Commented Aug 16, 2021 at 12:49
  • Can you share the URL instead ? Commented Aug 16, 2021 at 15:01

1 Answer 1

1

If you are able to click on drop down using :

elementt = driver.find_element_by_css_selector(".ui-dropdown")
driver.execute_script("arguments[0].click();", elementt)

then you should try :

driver.find_element_by_xpath("//span[text()='Alabma']/..").click() 

to click on option, also you can change the text as per requirement.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.