python Selenium options drop down
Question: I am new to python. I have a code in R that I am trying to replace with a
python script. I am running into issues getting python to select a value from
a drop down menu.

This is the code in R that worked:

    
    
    remDr$findElement(using = 'xpath', "//select[@id = 'groupby1']/option[@value = 'ReportDate']")$clickElement()
    

This is the HTML code:

    
    
    select style="" class="dropdown" name="groupby1" id="groupby1" accesskey="" waffle_affected_fields=""
    
    option value="ReportData">Report Date</option>
    

here are a couple things I tried after searching how to do this in python and
I keep running into errors.

    
    
    find_element_by_xpath("//select[@id='groupby1']/option[@value='ReportDate']").click()
    NameError: name 'find_element_by_xpath' is not defined
    
    Select(driver.find_element_by_css_selector("select#groupby1")).select_by_value('ReportDate').click()
    NameError: name 'Select' is not defined
    

Any help is appropriated!


Answer: These functions are properties of your `webdriver` instance. You need to do
something like this:

    
    
    from selenium import webdriver
    
    driver = webdriver.Firefox()
    driver.get("http://www.python.org")
    driver.find_element_by_xpath("//select[@id='groupby1']/option[@value='ReportDate']").click()
    

See the [getting started page](http://selenium-python.readthedocs.org/getting-
started.html) for examples.

