Forum Discussion

aa1's avatar
aa1
Contributor
2 years ago
Solved

Automation script in ReadyAPI for Authentication

Hi, I am new to Ready API. I am trying to authenticate the user credentials and set it up as the script inside Auth Manager so that we can run the ready API test suites from the pipeline automatically. Manual set up for authentication is working fine and we are able to call the APIs and get results. We use Oauth2.0 authentication. The automation script that I have is not working. I am not sure what I am missing.

This is what I tried referring to this document:  https://support.smartbear.com/readyapi/docs/requests/auth/types/oauth2/automate/index.html

var loginForm = document.querySelectorAll(".ab.cd");
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
var loginBtnForm = document.querySelector(".c2");
var loginBtn = document.querySelectorAll(".c3.c4.c5.c6.c7");

document.getElementById("username").value = "testusername";
document.getElementById("password").value = "testpassword";

loginBtn.click();

 

 

 

 

  • Hi aa1 

    The error message indicates that there is a missing semicolon (;) before a statement in the script.

    Looks the body variable is defined without a semicolon at the end of the line.

    Try adding a semicolon after body = [ grant_type: 'client_credentials', client_id: clientId ] like this:

    body = [ grant_type: 'client_credentials', client_id: clientId ];

    This should fix the error is what I believe – Give a try and let me know

6 Replies

No RepliesBe the first to reply