firefox
Selenium
Python3

Selenium のサンプル 予約フォーム (python3)

Selenium のサンプルです。

次のページをテストに使いました。
予約フォーム

reserve_form.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
#   reserve_form.py
#
#                   Sep/21/2018
#
# ------------------------------------------------------------------
import sys
from selenium.webdriver import Firefox

# ------------------------------------------------------------------
sys.stderr.write("*** 開始 ***\n")

url = 'http://example.selenium.jp/reserveApp/'

browser = Firefox()
browser.get(url)
#
browser.find_element_by_id('reserve_month').clear()
browser.find_element_by_id('reserve_month').send_keys("10")
browser.find_element_by_id('reserve_day').clear()
browser.find_element_by_id('reserve_day').send_keys("10")
browser.find_element_by_id('reserve_term').clear()
browser.find_element_by_id('reserve_term').send_keys("3")
browser.find_element_by_id('headcount').clear()
browser.find_element_by_id('headcount').send_keys("2")
#
str_select = "input[type='radio'][name='bf'][value='off']"
item=browser.find_elements_by_css_selector(str_select)[0]
item.click()
#
str_select = "input[type='checkbox'][id='plan_b']"
item=browser.find_elements_by_css_selector(str_select)[0]
item.click()
#
browser.find_element_by_id('guestname').clear()
browser.find_element_by_id('guestname').send_keys("明智小五郎")
#
browser.find_element_by_id('goto_next').click()
#
sys.stderr.write("*** 終了 ***\n")
#
# ------------------------------------------------------------------

実行方法

./reserve_form.py