Unable to select the desirable value from a dropdown list, it always selects the 1st one (Python, Selenium)

26 views Asked by At

I am trying to assign a user to a specific Mantis Bug using Python and Selenium. My code (below) when executed it always picks the 1st record (Alfred Kan) and not the one I manually select in my code (Bryan Lu). My code is below:

    driver.get("https://mantis-dev.{company}.com/bug_view_page.php?bug_id=0794544")
    form = driver.find_element(By.XPATH, '//form[@action="bug_assign.php"]')
    dropdown = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.CSS_SELECTOR, '.chosen-single'))
    )
    dropdown.click()
    
    driver.execute_script("arguments[0].click();", WebDriverWait(driver, 10).until
        (EC.element_to_be_clickable((By.XPATH, '//li[text()="Bryan Lu (bryanlu)"]'))))
    assign_button = driver.find_element(By.XPATH, '//input[@type="submit" and @value="Assign To:"]')
    assign_button.click()
    driver.quit()

This is the part of the Mantis Bug page that shows the dropdown

enter image description here

and this is the code-behind

enter image description here

I would appreciate any help, thank you

0

There are 0 answers