Skip to main content
getting to the point
Source Link
user246
user246

Selecting multiple options and deselecting options using Selenium with python

I am trying to open a webpage and select options before submitting the form. The issue I am having is being able to selecting more than one option in the select box. Eventually I want to be able to deselect an option as well and submit the the form.

I am a relative beginner with python so any help would appreciated. A snippet of the relevant html and python code is below

Snippet of html:

<select size="10" name="ctl00$MainContent$lbCommodity" multiple="multiple" id="ctl00_MainContent_lbCommodity">
    <option value="101">Wheat - HRW</option>
    <option value="102">Wheat - SRW</option>
    <option value="103">Wheat - HRS</option>
    <option value="104">Wheat - White</option>
    <option value="105">Wheat - Durum</option>

Python code:

driver = webdriver.Chrome()
driver.get("http://apps.fas.usda.gov/esrquery/esrq.aspx")
driver.find_element_by_xpath("//select[@name='ctl00$MainContent$lbCommodity']/option[@value='801']").click()

Any help is greatly appreciated

Selecting multiple options using Selenium with python

I am trying to open a webpage and select options before submitting the form. The issue I am having is being able to selecting more than one option in the select box. Eventually I want to be able to deselect an option as well and submit the the form.

I am a relative beginner with python so any help would appreciated. A snippet of the relevant html and python code is below

Snippet of html:

<select size="10" name="ctl00$MainContent$lbCommodity" multiple="multiple" id="ctl00_MainContent_lbCommodity">
    <option value="101">Wheat - HRW</option>
    <option value="102">Wheat - SRW</option>
    <option value="103">Wheat - HRS</option>
    <option value="104">Wheat - White</option>
    <option value="105">Wheat - Durum</option>

Python code:

driver = webdriver.Chrome()
driver.get("http://apps.fas.usda.gov/esrquery/esrq.aspx")
driver.find_element_by_xpath("//select[@name='ctl00$MainContent$lbCommodity']/option[@value='801']").click()

Any help is greatly appreciated

Selecting multiple options and deselecting options using Selenium with python

I am trying to open a webpage and select options before submitting the form. The issue I am having is being able to selecting more than one option in the select box. Eventually I want to be able to deselect an option as well and submit the the form.

A snippet of the relevant html and python code is below

Snippet of html:

<select size="10" name="ctl00$MainContent$lbCommodity" multiple="multiple" id="ctl00_MainContent_lbCommodity">
    <option value="101">Wheat - HRW</option>
    <option value="102">Wheat - SRW</option>
    <option value="103">Wheat - HRS</option>
    <option value="104">Wheat - White</option>
    <option value="105">Wheat - Durum</option>

Python code:

driver = webdriver.Chrome()
driver.get("http://apps.fas.usda.gov/esrquery/esrq.aspx")
driver.find_element_by_xpath("//select[@name='ctl00$MainContent$lbCommodity']/option[@value='801']").click()
Add code callouts
Source Link
Kate Paulk
  • 31.5k
  • 8
  • 55
  • 109

I am trying to open a webpage and select options before submitting the form. The issue I am having is being able to selecting more than one option in the select box. Eventually I want to be able to deselect an option as well and submit the the form.

I am a relative beginner with python so any help would appreciated. A snippet of the relevant html and python code is below

Snippet of html: Wheat - HRW Wheat - SRW Wheat - HRS Wheat - White Wheat - Durum

<select size="10" name="ctl00$MainContent$lbCommodity" multiple="multiple" id="ctl00_MainContent_lbCommodity">
    <option value="101">Wheat - HRW</option>
    <option value="102">Wheat - SRW</option>
    <option value="103">Wheat - HRS</option>
    <option value="104">Wheat - White</option>
    <option value="105">Wheat - Durum</option>

Python code: driver = webdriver.Chrome() driver.get("http://apps.fas.usda.gov/esrquery/esrq.aspx") driver.find_element_by_xpath("//select[@name='ctl00$MainContent$lbCommodity']/option[@value='801']").click()

driver = webdriver.Chrome()
driver.get("http://apps.fas.usda.gov/esrquery/esrq.aspx")
driver.find_element_by_xpath("//select[@name='ctl00$MainContent$lbCommodity']/option[@value='801']").click()

Any help is greatly appreciated

I am trying to open a webpage and select options before submitting the form. The issue I am having is being able to selecting more than one option in the select box. Eventually I want to be able to deselect an option as well and submit the the form.

I am a relative beginner with python so any help would appreciated. A snippet of the relevant html and python code is below

Snippet of html: Wheat - HRW Wheat - SRW Wheat - HRS Wheat - White Wheat - Durum

Python code: driver = webdriver.Chrome() driver.get("http://apps.fas.usda.gov/esrquery/esrq.aspx") driver.find_element_by_xpath("//select[@name='ctl00$MainContent$lbCommodity']/option[@value='801']").click()

Any help is greatly appreciated

I am trying to open a webpage and select options before submitting the form. The issue I am having is being able to selecting more than one option in the select box. Eventually I want to be able to deselect an option as well and submit the the form.

I am a relative beginner with python so any help would appreciated. A snippet of the relevant html and python code is below

Snippet of html:

<select size="10" name="ctl00$MainContent$lbCommodity" multiple="multiple" id="ctl00_MainContent_lbCommodity">
    <option value="101">Wheat - HRW</option>
    <option value="102">Wheat - SRW</option>
    <option value="103">Wheat - HRS</option>
    <option value="104">Wheat - White</option>
    <option value="105">Wheat - Durum</option>

Python code:

driver = webdriver.Chrome()
driver.get("http://apps.fas.usda.gov/esrquery/esrq.aspx")
driver.find_element_by_xpath("//select[@name='ctl00$MainContent$lbCommodity']/option[@value='801']").click()

Any help is greatly appreciated

Source Link
Moj
  • 1
  • 1
  • 1

Selecting multiple options using Selenium with python

I am trying to open a webpage and select options before submitting the form. The issue I am having is being able to selecting more than one option in the select box. Eventually I want to be able to deselect an option as well and submit the the form.

I am a relative beginner with python so any help would appreciated. A snippet of the relevant html and python code is below

Snippet of html: Wheat - HRW Wheat - SRW Wheat - HRS Wheat - White Wheat - Durum

Python code: driver = webdriver.Chrome() driver.get("http://apps.fas.usda.gov/esrquery/esrq.aspx") driver.find_element_by_xpath("//select[@name='ctl00$MainContent$lbCommodity']/option[@value='801']").click()

Any help is greatly appreciated