commit
4c911cc99f
1 changed files with 111 additions and 0 deletions
@ -0,0 +1,111 @@ |
|||||
|
local err |
||||
|
print("BEFORE JSON LOADING payload: " .. json_payload) |
||||
|
local json = require("json") |
||||
|
print("AFTER JSON LOADING") |
||||
|
-- Parse the JSON string |
||||
|
local obj, err = json.decode(json_payload) |
||||
|
|
||||
|
print("Cuit:" .. obj["cuit"]) |
||||
|
print("Password:" .. obj["password"]) |
||||
|
|
||||
|
cuit = obj["cuit"] |
||||
|
password = obj["password"] |
||||
|
|
||||
|
print("Iniciando login AFIP") |
||||
|
err = navigate("https://auth.afip.gob.ar/contribuyente_/login.xhtml") |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
err = waitVisibleByQuerySelector("input[name='F1:username']") |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
err = setTextFieldByQuerySelector("input[name='F1:username']", "") |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
waitSecs(2) |
||||
|
|
||||
|
err = inputTextFieldByQuerySelector("input[name='F1:username']", cuit) |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
waitSecs(2) |
||||
|
|
||||
|
err = clickElementByQuerySelector("input[id=\"F1:btnSiguiente\"]") |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
local error_on_page |
||||
|
|
||||
|
js_script = [[ |
||||
|
const errorSpan = document.querySelector('span#F1\\:msg'); |
||||
|
errorSpan ? errorSpan.textContent : ''; |
||||
|
]] |
||||
|
|
||||
|
error_on_page, err = evaluateJsWithStringOutput(js_script) |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
if error_on_page ~= "" then |
||||
|
print("Error on page:" .. error_on_page) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
waitSecs(2) |
||||
|
|
||||
|
err = waitVisibleByQuerySelector("input[name='F1:password']") |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
err = inputTextFieldByQuerySelector("input[name='F1:password']", password) |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
err = clickElementByQuerySelector("input[id=\"F1:btnIngresar\"]") |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
waitSecs(2) |
||||
|
error_on_page, err = evaluateJsWithStringOutput(js_script) |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
print("Error on page:" .. error_on_page) |
||||
|
if error_on_page:match("^%s*(.-)%s*$") ~= "" then |
||||
|
print("Error on page:" .. error_on_page) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
current_url, err = getCurrentUrl() |
||||
|
if err then |
||||
|
print(err) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
if string.match(current_url, "^https://auth%.afip%.gob%.ar/contribuyente_/login%.xhtml") then |
||||
|
print("Unexpected URL after login: " .. current_url) |
||||
|
return |
||||
|
end |
||||
|
|
||||
|
print("Login successful desde LUA!!") |
||||
Loading…
Reference in new issue