0

I need, click a dropdown menü element. But I'm new Selenium Webdriver and I cant find anything

<div class="sort-fltr-cntnr"><select>
<option value="SCORE">Önerilen</option>
<option value="PRICE_BY_ASC">En Düşük Fiyat</option>
<option value="PRICE_BY_DESC">En Yüksek Fiyat</option>
<option value="MOST_RECENT">En Yeniler</option>
<option value="BEST_SELLER">Çok Satanlar</option> ....

Its my code:

dropdown = self.driver.find_element(By.CSS_SELECTOR, "select")
element=dropdown.find_element(By.XPATH, "//option[. = 'Önerilen']")
self.driver.execute_script("arguments[0].click();", element)
time.sleep()
dropdown.find_element(By.XPATH, "//option[. = 'En Düşük Fiyat']").click()

An given a error:

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //option[. = 'Önerilen']
1

1 Answer 1

1
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select

select = Select(WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "sort-fltr-cntnr"))))
select.select_by_value('SCORE')

Simply wait for the class name with sort to be clickable and then select the score value.

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.