0 votes
1 view
in DevOps and Agile by (19.8k points)

I want to select a value from a drop-down option. The HTML is as follows:

<span id="searchTypeFormElementsStd">

    <label for="numReturnSelect"></label>

    <select id="numReturnSelect" name="numReturnSelect">

        <option value="200"></option>

        <option value="250"></option>

        <option value="500"></option>

        <option selected="" value="200"></option>

        <option value="800"></option>

        <option value="15000"></option>

        <option value="85000"></option>



I tried as follows:


What is wrong with it? Please help me with code!

1 Answer

0 votes
by (63.4k points)

Use this code:

from selenium.webdriver.support.ui

import Select driver = webdriver.Ie(".\\IEDriverServer.exe") 

driver.get("https://test.com") select = Select(driver.find_element_by_xpath("""//input[@name='n_name']""")) 

select.select_by_index(2) select.select_by_visible_text('Visible Text')


Welcome to Intellipaat Community. Get your technical queries answered by top developers !