How to do it...

  1. Import Selenium, start a browser, and load the form page. A page will open reflecting the operations:
>>> from selenium import webdriver
>>> browser = webdriver.Chrome()
>>> browser.get('https://httpbin.org/forms/post')
Note the banner with Chrome is being controlled by automated test software.
  1. Add a value in the Customer name field. Remember that it is called custname:
>>> custname = browser.find_element_by_name("custname")
>>> custname.clear()
>>> custname.send_keys("Sean O'Connell")

The form will update:

  1. Select the pizza size as medium:
>>> for size_element in browser.find_elements_by_name("size"):
... if size_element.get_attribute('value') == 'medium':
... size_element.click()
...
>>>

This will change the pizza size ratio box.

  1. Add bacon and cheese:
>>> for topping in browser.find_elements_by_name('topping'):
... if topping.get_attribute('value') in ['bacon', 'cheese']:
... topping.click()
...
>>>

Finally, the checkboxes will appear as marked:

  1. Submit the form. The page will submit and the result will be displayed:
>>> browser.find_element_by_tag_name('form').submit()

The form will be submitted and the result from the server will be displayed:

  1. Close the browser:
>>> browser.quit()