Contributions
Re: Automation script in ReadyAPI for Authentication
Hi Humashankar I tried the following but it gives me an error message. Something is missing in my code. @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1'); import groovyx.net.http.RESTClient; import groovyx.net.http.HTTPBuilder import groovyx.net.http.Method import groovyx.net.http.ContentType def clientId = "5LM"; def redirectUri = "https://readyapi/callback"; def authorizationUrl = "https://abc.com/authorize"; def authUrl = "${authorizationUrl}?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=token"; //def clientSecret = ?; def http = new HTTPBuilder(tokenUrl) http.request(Method.POST, ContentType.URLENC) { req -> body = [ grant_type: 'client_credentials', client_id: clientId ] response.success = { resp, reader -> // Extract the access token from the response def accessToken = resp.data.access_token // Now we can use the access token to make API requests println accessToken //println "Please visit the following URL to grant access:\n${authUrl}"; This is the error I get: The following script is invalid: @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1'); import groovyx.net.http.RESTClient; import groovyx.net.http.HTTPBuilder import groovyx.net.http.Method import groovyx.net.http.ContentType def clientId = "5LM"; def redirectUri = "https://readyapi/callback"; def authorizationUrl = "https://abc.com/authorize"; def authUrl = "${authorizationUrl}?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=token"; //def clientSecret = ?; def http = new HTTPBuilder(tokenUrl) http.request(Method.POST, ContentType.URLENC) { req -> body = [ grant_type: 'client_credentials', client_id: clientId ] response.success = { resp, reader -> // Extract the access token from the response def accessToken = resp.data.access_token // Now we can use the access token to make API requests println accessToken //println "Please visit the following URL to grant access:\n${authUrl}"; Error: missing ; before statement (scriptToValidate#2)2 months agoPlace ReadyAPI QuestionsReadyAPI Questions0Views1like2CommentsRe: Automation script in ReadyAPI for Authentication
Hi Humashankar , Thank you for your reply. I looked into Groovy script. Did you mean something like this? @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1') import groovyx.net.http.RESTClient def clientId = "a1b2" def redirectUri = "https://readyapi/callback" def authorizationUrl = "https://abc.com/authorize" def authUrl = "${authorizationUrl}?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=token" def accessToken = "" def url = new URL(redirectUri) def params = url.fragment.split('&') params.each { param -> def parts = param.split('=') if (parts[0] == 'access_token') { accessToken = parts[1] } } if (accessToken) { def restClient = new RESTClient('') restClient.auth.oauth2(accessToken) def response = restClient.get(path: '/resource', contentType: 'application/json') println "Response: ${response.status} - ${response.data}" } else { println "Failed to retrieve access token" } Best regards, aa12 months agoPlace ReadyAPI QuestionsReadyAPI Questions2Views1like4CommentsAutomation 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();99Views1like6CommentsLoadComplete trial
Hello, I am looking to acquire a trial version of loadcomplete tool. I tried downloading it but somehow I get redirected to load ninja instead. Load ninja would have worked for me but it only supports 15 virtual users which is not enough for me. Loadcomplete would have given me 50 users even for the trial version. If anyone could point me in the right direction, I would be grateful. I had created a support case last week but I haven't received any response yet. Thank you in advance,1.1KViews0likes0CommentsRe: Event handler for textbox
Aliases.browser.page.form.textboxCreditCardNumber.Keys(""); Aliases.browser.page.form.textboxCreditCardNumber.Keys("4110044510001234[Enter]"); Aliases.browser.page.panel.panel.textboxCreditCardExpirationDate.Keys(""); Aliases.browser.page.panel.panel.textboxCreditCardExpirationDate.Keys("12[Enter]"); Aliases.browser.page.panel.panel.textboxExpirydateyear.Keys(""); Aliases.browser.page.panel.panel.textboxExpirydateyear.Keys("2022"); Aliases.browser.page.form.textboxCvvNumber.Keys(""); Aliases.browser.page.form.textboxCvvNumber.Keys("123"); Aliases.browser.page.form.textboxCvvNumber.Keys("[Enter]"); Aliases.browser.page.panel.panel.textboxExpirydateyear.Keys("[Tab]"); Aliases.browser.page.panel.panel.textboxExpirydateyear.Keys("2022"); Aliases.browser.page.panel.panel.textboxExpirydateyear.Keys("[Enter]"); aqUtils.Delay(ProjectSuite.Variables.ExistsTimeout); Runner.Pause(); var btnPayNow = Aliases.browser.page.panel.panel2.buttonPayNow; while (! btnPayNow.Exists) { aqUtils.Delay(ProjectSuite.Variables.ExistsTimeout); btnPayNow = page.NativeWebObject.Find("class", "Pay now", "btn btn-primary"); } btnPayNow.Click(); The above code is what I tried. I tried SetText as well. When it comes to the last line, it fails saying the button is disabled.2.2KViews0likes1CommentEvent handler for textbox
Hi, I have a situation where I have an amount text box and then Pay now button beneath it. When I enter the amount, the pay now button should be enabled and then the next step is to click on it. This is an automated script in Jscript. When I do manually, as soon as I enter the text, the pay button does get enabled. But when my automated script runs, it does settext in the textbox but then the button is still disabled. So the next event of clicking on it fails with the exception that the button is disabled. I tried to enable it but seems like I need to have an event handler for this. Do I write the event handler when the textbox has been filled in. Or may be in tab out from that textbox. Please help me to find the right approach. thanksSolved2.2KViews0likes8CommentsRe: Regex
Hi again, Furthermore, looks like testcomplete has its own non native regex methods. So I was trying those but that did not take me anywhere either. For example: var testString = "agent_1d74901d5"; var testRegex = /\agent\_\a/; var re = new RegExp(testRegex); var rr = re.test(testString); I dont understand why rr is false. Is that not how you would specify the regex? thanks aa1.7KViews0likes1CommentRe: Regex
Hi Wamboo, Thank you for the reply.I need it for automation script. I am using test complete to compare two html files - actual vs. expected. But there are some of the lines that I would like to ignore. So I want to use regex to find those lines and replace with a whitespace or some characteres so that the testcomplete passes the test. Right now I drilled down to very simple expression: Example: If i try regex tester such as http://regexstorm.net/tester,, it shows 1 match but test complete says 0 match for the following so I am assuming regex dont work the same way asit normally does in test complete. var test1 = "agent_1a2b3c_LangPref_0"; var regEx = "(?<=agent_).*?(?=_)"; var ppp = aqString.StrMatches(regEx,test1); Test complete gives ppp = false which means it did not find any match. I dont seem to understand why. You have any ideas? Regards, aa1.7KViews0likes2Comments