Skip to content

Instantly share code, notes, and snippets.

@rsicarelli
Created October 8, 2021 13:54
Show Gist options
  • Select an option

  • Save rsicarelli/0e54ddbb725bede17eefbf1e7cdff417 to your computer and use it in GitHub Desktop.

Select an option

Save rsicarelli/0e54ddbb725bede17eefbf1e7cdff417 to your computer and use it in GitHub Desktop.
Valencia 'administraction' publica cita web automation
/* Instructions
- Downlaod and install https://ui.vision/
- Open the chrome extension
- On top left, click on the small folder with plus icon
- Select "Import JSON"
- Import this file
*/
/* Running
- Select the "valencia cita automation" macro
- On top right, click on the little arrow down button (after play macro)
- Click on "Play loop."
- Set some big value like 999999
- Click play and let it play :)
*/
/* Customizing
- Either edit this json and reimport or change in the GUI
- On step 6 and 9, replace the value with the target location of your preference
- On step 13 and 14 replace with your data
- on Step 21, update the script and replace TELEGRAM_API_KEY and GROUP_ID
*/
/* Notes
- Prefer creating an empty profile on chrome since the automation closes and open the entire browser
*/
{
"Name": "Valencia citas",
"CreationDate": "2021-7-29",
"Commands": [
{
"Command": "comment",
"Target": "selectWindow // tab=open",
"Value": "https://sede.administracionespublicas.gob.es/icpplus/index.html",
"Description": ""
},
{
"Command": "open",
"Target": "https://sede.administracionespublicas.gob.es/icpplus/index.html",
"Value": "",
"Description": ""
},
{
"Command": "select",
"Target": "id=form",
"Value": "label=Valencia",
"Targets": [
"id=form",
"name=form",
"xpath=//*[@id=\"form\"]",
"xpath=//select[@id='form']",
"xpath=//select",
"css=#form"
],
"Description": ""
},
{
"Command": "click",
"Target": "xpath=//*[@id=\"form\"]/option[50]",
"Value": "",
"Targets": [
"xpath=//*[@id=\"form\"]/option[50]",
"xpath=//option[@value='/icpplus/citar?p=46&locale=es']",
"xpath=//option[50]",
"css=#form > option:nth-child(50)"
],
"Description": ""
},
{
"Command": "clickAndWait",
"Target": "id=btnAceptar",
"Value": "",
"Targets": [
"id=btnAceptar",
"xpath=//*[@id=\"btnAceptar\"]",
"xpath=//input[@id='btnAceptar']",
"xpath=//div[3]/input",
"css=#btnAceptar"
],
"Description": ""
},
{
"Command": "select",
"Target": "id=sede",
"Value": "label=CNP-COMISARIA DE BAILEN, Bailen, 9",
"Targets": [
"id=sede",
"name=sede",
"xpath=//*[@id=\"sede\"]",
"xpath=//select[@id='sede']",
"xpath=//select",
"css=#sede"
],
"Description": ""
},
{
"Command": "click",
"Target": "xpath=//*[@id=\"sede\"]/option[8]",
"Value": "",
"Targets": [
"xpath=//*[@id=\"sede\"]/option[8]",
"xpath=//option[@value='4']",
"xpath=//option[8]",
"css=#sede > option:nth-child(9)"
],
"Description": ""
},
{
"Command": "select",
"Target": "id=tramiteGrupo[0]",
"Value": "label=POLICIA-CERTIFICADO DE REGISTRO DE CIUDADANO DE LA U.E.",
"Targets": [
"id=tramiteGrupo[0]",
"name=tramiteGrupo[0]",
"xpath=//*[@id=\"tramiteGrupo[0]\"]",
"xpath=//select[@id='tramiteGrupo[0]']",
"xpath=//div[2]/div/div/fieldset/div/select",
"css=#tramiteGrupo[0]"
],
"Description": ""
},
{
"Command": "click",
"Target": "xpath=//*[@id=\"tramiteGrupo[0]\"]/option[2]",
"Value": "",
"Targets": [
"xpath=//*[@id=\"tramiteGrupo[0]\"]/option[2]",
"xpath=//option[@value='4038']",
"xpath=//div[2]/div/div/fieldset/div/select/option[2]",
"css=#tramiteGrupo[0] > option:nth-child(2)"
],
"Description": ""
},
{
"Command": "clickAndWait",
"Target": "id=btnAceptar",
"Value": "",
"Targets": [
"id=btnAceptar",
"xpath=//*[@id=\"btnAceptar\"]",
"xpath=//input[@id='btnAceptar']",
"xpath=//div[4]/input",
"css=#btnAceptar"
],
"Description": ""
},
{
"Command": "clickAndWait",
"Target": "id=btnEntrar",
"Value": "",
"Targets": [
"id=btnEntrar",
"xpath=//*[@id=\"btnEntrar\"]",
"xpath=//input[@id='btnEntrar']",
"xpath=//div[3]/input",
"css=#btnEntrar"
],
"Description": ""
},
{
"Command": "click",
"Target": "id=txtIdCitado",
"Value": "",
"Targets": [
"id=txtIdCitado",
"name=txtIdCitado",
"xpath=//*[@id=\"txtIdCitado\"]",
"xpath=//input[@id='txtIdCitado']",
"xpath=//div[2]/input",
"css=#txtIdCitado"
],
"Description": ""
},
{
"Command": "type",
"Target": "id=txtIdCitado",
"Value": "//YOUR PASSPORT",
"Targets": [
"id=txtIdCitado",
"name=txtIdCitado",
"xpath=//*[@id=\"txtIdCitado\"]",
"xpath=//input[@id='txtIdCitado']",
"xpath=//div[2]/input",
"css=#txtIdCitado"
],
"Description": ""
},
{
"Command": "type",
"Target": "id=txtDesCitado",
"Value": "//YOUR NAME",
"Targets": [
"id=txtDesCitado",
"name=txtDesCitado",
"xpath=//*[@id=\"txtDesCitado\"]",
"xpath=//input[@id='txtDesCitado']",
"xpath=//div[3]/div/div/div/div/input",
"css=#txtDesCitado"
],
"Description": ""
},
{
"Command": "clickAndWait",
"Target": "id=btnEnviar",
"Value": "",
"Targets": [
"id=btnEnviar",
"xpath=//*[@id=\"btnEnviar\"]",
"xpath=//input[@id='btnEnviar']",
"xpath=//form/div/div/div[2]/input",
"css=#btnEnviar"
],
"Description": ""
},
{
"Command": "clickAndWait",
"Target": "id=btnEnviar",
"Value": "",
"Targets": [
"id=btnEnviar",
"xpath=//*[@id=\"btnEnviar\"]",
"xpath=//input[@id='btnEnviar']",
"xpath=//div[2]/input",
"css=#btnEnviar"
],
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"mainWindow\"]/div/div/section/div[2]/form/div/p",
"Value": "citaResult",
"Description": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "var result = ${citaResult}.replace(/(\\r\\n|\\n|\\r)/gm, \"\"); return result",
"Value": "formattedText",
"Description": ""
},
{
"Command": "echo",
"Target": "${formattedText}",
"Value": "",
"Description": ""
},
{
"Command": "gotoIf_v2",
"Target": "(${formattedText}.includes(\"En este momento no hay citas disponibles.En breve, la Oficina pondrá a su disposición nuevas citas.\")) == true",
"Value": "ASSERT-SUCCEEDED",
"Description": ""
},
{
"Command": "comment",
"Target": "executeScript_Sandbox // var xhttp = new XMLHttpRequest(); xhttp.open(\"POST\", \"https://api.telegram.org/${TELEGRAM_API_KEY}/sendMessage?chat_id=${GROUP_ID}&text=It seems that are available citas\", true); xhttp.send();",
"Value": "",
"Description": ""
},
{
"Command": "label",
"Target": "ASSERT-SUCCEEDED",
"Value": "",
"Description": ""
},
{
"Command": "comment",
"Target": "deleteAllCookies // ",
"Value": "",
"Description": ""
},
{
"Command": "comment",
"Target": "pause // ",
"Value": "60000",
"Description": ""
},
{
"Command": "click",
"Target": "id=btnSalir",
"Value": "",
"Targets": [
"id=btnSalir",
"xpath=//*[@id=\"btnSalir\"]",
"xpath=//input[@id='btnSalir']",
"xpath=//div[2]/input",
"css=#btnSalir"
],
"Description": ""
},
{
"Command": "selectWindow",
"Target": "tab=close",
"Value": "",
"Description": ""
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment