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.jsonURL: URL to the MS formEMAIL: Your emailPASSWORD: Your passwordRECEIPT:trueif you wantSend me an email receipt of my responsesoption to be checkedHEADLESS:trueif you want to run the browser in headless modeHEADLESS_LOGIN:trueif 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"]
}
}typecan be one ofselect | radio | checkbox | text | textareavaluesis required forcheckboxvalueis 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