Submit MS forms by puppeteer
Create .env file in the root directory and add the following variables
URL=URL_TO_MS_FORM
EMAIL=YOUR_EMAIL
PASSWORD=YOUR_PASSWORD
RECEIPT=true
HEADLESS=true
HEADLESS_LOGIN=false
QUESTION_FILE=./questions.json
URL
: URL to the MS formEMAIL
: Your emailPASSWORD
: Your passwordRECEIPT
:true
if you wantSend me an email receipt of my responses
option to be checkedHEADLESS
:true
if you want to run the browser in headless modeHEADLESS_LOGIN
:true
if you dont have MFA enabled (highly unlikely). If you have MFA enabled, set it to falseQUESTION_FILE
: Path to the JSON file containing the answers to the questions
JSON Format for questions is as follows
{
"QUESTION_ID": {
"type": "select",
"value": "Option 1",
"values": ["Option 2", "Option 3"]
}
}
type
can be one ofselect | radio | checkbox | text | textarea
values
is required forcheckbox
value
is required for all other types
For radio
, checkbox
:
Inspect the input element (radio
, checkbox
) and copy the value of name
attribute.
For select
, text
and textarea
:
Inspect the element and copy the value of aria-labelledby
. The value is formatted like QuestionId_{QUESTION_ID} QuestionInfo_${QUESTION_ID}
.
You can either use npm run start
or directly execute node index.js
.
CronTab Command
E.g. 5 4 * * TUE cd /path/to/script/ && nvm use && node index.js
At 04:05 on Tuesday