pycharmers.cli.form_auto_fill_in module¶
-
pycharmers.cli.form_auto_fill_in.form_auto_fill_in(argv=['-M', 'html', '.', '_build'])[source]¶ Auto fill in your form using your saved information (or answer on the spot).
- Parameters
path (str) – Path to environment file.
-remain-unchanged (bool) – Whether you want to update and memorize your answer. (default=
True)-Y/--yes (bool) – Automatic yes to prompts.
--quiet (bool) – Whether you want to be quiet or not. (default=
False)--browser (bool) – Whether you want to run Chrome with GUI browser. (default=
True)-P/--params (KwargsParamProcessor) – Specify the kwargs. You can specify by
-P username=USERNAME-P password=PASSWORD--show-data (bool) – Print the data in path.
Note
When you run from the command line, execute as follows:
$ form-auto-fill-in UHMRF --yes -P "username=USERNAME" -P "password=PASSWORD" $ form-auto-fill-in UHMRF --show-data $ form-auto-fill-in
Examples
>>> # Run in terminal >>> form-auto-fill-in UHMRF --show-data { "name": "UTokyo Health Management Report Form", "URL": "https://forms.office.com/Pages/ResponsePage.aspx?id=XXXXX", "login": { "0": { "func": "send_keys", "by": "xpath", : } : } >>> form-auto-fill-in +--------------+--------------------------------------+ | Abbreviation | Name | +==============+======================================+ | UHMRF | UTokyo Health Management Report Form | +--------------+--------------------------------------+ | _sample | SAMPLE FORMS | +--------------+--------------------------------------+
-
class
pycharmers.cli.form_auto_fill_in.AutoFillInForms(path, verbose=True, **kwargs)[source]¶ Bases:
objectIf you want to create your own gateway class, please inherit this class.
- Parameters
path (str) – Path to json data that describes the procedure of form.
verbose (bool) – Whether to print message or not. (default=
True)
-
print¶ Print function according to
verbose- Type
function
-
data¶ Data that describes the procedure of form.
- Type
dict
-
path¶ Path to json data that describes the procedure of form.
- Type
str
-
SUPPORTED_FORM_TYPES= ['radio', 'checkbox', 'text']¶
-
DOMAIN2FORM= {'forms.office.com': 'office'}¶
-
static
load_data(path)[source]¶ Load data from json file.
- Parameters
path (str) – Path to json file.
-
static
save_data(path, data, indent=2, update=True)[source]¶ Save data at
self.path- Parameters
path (str) – Path to json file.
indent (int) – If
indentis a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines.Noneis the most compact representation.update (bool) – Whether to update
"last_date"variable.
-
static
whichForms(url)[source]¶ Decide which Forms from the domain of the
url- Parameters
url (str) – URL of the forms.
- Returns
Identifier of the forms.
- Return type
str
-
static
show_curt_browser(driver)[source]¶ Visualize the current browser by taking screenshots
- Parameters
driver (WebDriver) – Selenium WebDriver.
-
static
answer_question(qno, ans_data={}, inputElements=[], need_check=False)[source]¶ Answer each question.
- Parameters
qno (int) – Question number in the form.
inputElements (list) – List of input elements in the form.
need_check (bool) – Whether you need to check the value when using the value in environment file. (default=
False)
- Returns
{"no": no, "val": val}- Return type
dict
-
login(driver, url, login_data={})[source]¶ Perform the login procedure required to answer the form.
- Parameters
driver (WebDriver) – Selenium WebDriver.
url (str) – URL of the form.
login_data (dict) – Data required for login.
-
run(browser=False, **kwargs)[source]¶ - Parameters
browser (bool) – Whether you want to run Chrome with GUI browser. (default=
False)
-
dev_run(browser=True, **kwargs)[source]¶ - Parameters
browser (bool) – Whether you want to run Chrome with GUI browser. (default=
True)WebDriver – Selenium WebDriver.