SundaytwinsOccasional ContributorJoined 9 years ago19 Posts4 LikesLikes received3 SolutionsView All Badges
ContributionsMost RecentMost LikesSolutionsRe: Sync call with Oauth2 needed in Testcomplete Hi Alex, Thanks for your response. Eventually we found a solution. I'll include my code in this ticket for others to use. It was not an easy journey to find this. To respond to your question: we use Testcomplete to do web UI testing, but occasionally we need to do some API calls to make our live a bit easier. (mostly to do 'shorter steps' where if scripted to do it by UI, too heavy or not relevant for the running test). function httpPostRequestBearer() { var username = "<username>"; var password = "<password>"; var keycloakurl = "https://<authentication client URL>"; const params = { username: username, password: password, client_id: '<cliend-id>', client_secret: '<client-secret>', grant_type: 'password' }; const data = Object.keys(params) .map((key) => `${key}=${encodeURIComponent(params[key])}`) .join('&'); var tempBody = data // Define the request body JSON string var requestBody = tempBody; // Create the aqHttpRequest object var aqHttpRequest = aqHttp.CreatePostRequest(keycloakurl); // Specify the Content-Type header value aqHttpRequest.SetHeader("Content-Type","application/x-www-form-urlencoded"); // Send the request, create the aqHttpResponse object var aqHttpResponse = aqHttpRequest.Send(requestBody) var token = JSON.parse(aqHttpResponse.Text).access_token return token; } function httpPostRequest(param,bearertoken) { var address = "https://<url for service needing a token>"; var tempBody = '{ <your body possibly inserting your param from argumentlist> }' // Define the request body JSON string var requestBody = tempBody; // Create the aqHttpRequest object var aqHttpRequest = aqHttp.CreatePostRequest(address); // Specify the Content-Type header value aqHttpRequest.SetHeader("Content-Type", "application/json"); aqHttpRequest.SetHeader("Authorization", "bearer "+bearertoken); // Send the request, create the aqHttpResponse object var aqHttpResponse = aqHttpRequest.Send(requestBody) if (aqHttpResponse != null) { // Read the response data Log.Message(aqHttpResponse.AllHeaders); // All headers Log.Message(aqHttpResponse.GetHeader("Content-Type")); // A specific header Log.Message(aqHttpResponse.StatusCode); // A status code Log.Message(aqHttpResponse.StatusText); // A status text Log.Message(aqHttpResponse.Text); // A response body var JSONobj = JSON.parse(aqHttpResponse.Text); } return JSONobj } The code may not be the 'cleanest' but it does the job. The first function will get the bearer token and the second function is a POST call using the bearer token from the first passed by as an argument. The code has been cleaned to not have my exact calls of course, but it will provide an idea how we tackled it. Hope someone can enjoy it later too. 😊 Sync call with Oauth2 needed in Testcomplete We are currently struggling to make a synchronuous call with an OAuth2 authentication in Testcomplete. Previously we had a similar call using Basic Authentication to do the same, but recently we had to comply with security rules and this endpoint has been changed to have a OAuth2 authentication. Does anyone has a relevant experience with this? We use Testcomplete with JS scripting to have everything done. But this call is baffling us a bit. In particular, we need to have this kind of conversation : {'content-type': 'application/x-www-form-urlencoded' } Thanks in advance for any help. SolvedRe: FF download dialog box not recognised anymore The problem seems to solve itself by doing the latest updates.... Sorry to bother you all. Enjoy your testing! FF download dialog box not recognised anymore Hi All, Recently, my script that could save a file from a FF dialog box stopped working. At the moment, TC doesn't seem to recognize the FF download dialog box anymore as an object. This means also that the OpenFile.SaveFile does not work in this case as this is also relying on the fact that you can identify the object. We are only using the Web module (and that worked before). Any idea how to tackle this problem? Thanks in advance. SolvedRe: Integration TestRail and TestComplete Hi, I created a framework in Testcomplete that will read the tests inside a test run with a given test run-id. Then, it would execute the corresponding test cases as read from the test run. At the end of each test case execution, the result of the test was returned via the API into TestRail. As far as i know, there is no possibility to 'start' a test run or test case execution from within TestRail towards a (connected) Testtool. Hope this helps. I'm gladly willing to share the framework as it is built in Testcomplete. (12 i believe, it has been a while... ) Good luck! Re: Chrome does not react on TestComplete 12 Hi Adam, Meanwhile, I was helped correctly with the SmartBear Servicedesk. It seemed that i (unwantingly) deleted a counter, which should have made me jump to my next browser (chrome) but instead, he relaunched my first browser (ie). As we all know, the process of IE takes a time to close down, so when starting up the next (cross-browser) tests, it detected 'browser already running' (as that was IE closing down) and did not want to continue. I mistakenly thought Chrome was not recognised. Meanwhile all problems have been solved and TC 12 is working as steadily as before. So no need to be afraid of switching to TC12. Hope it helps! Good luck. Dominic PS. to help everyone. The last three lines (in the above code) should have read: browserindex = browserindex + 1 Call Aliases.browser.BrowserWindow.Close(5000) Wend Re: Chrome does not react on TestComplete 12 Hi Alex, Thanks for your response. Unfortunately, this is not the solution to the problem :-( Meanwhile i tried different things upto a complete reinstall of TC and Chrome on my machine (including a reboot after deletion). It won't help. Luckily, I have TC11 still on my PC. I can continue to work, as TC11 does my scripts without hesitation (also the Chrome browser parts). I logged an incident with the helpdesk. I'm intrigued why this is not working for TC12.... and wondered whether there are no fellow testers having the same problem.... Chrome does not react on TestComplete 12 Hi all, This morning i upgraded to TestComplete 12. After that,my scripts that worked fine on TC11 don't react to Chrome anymore. I can see in the log that 'The browser is already running' (which is not true by the way) and then he tries to navigate to a page, but never reaches it as Chrome never (visible or invisible) opens. Any one with the same problem? Basically this is the code: BrowserItems = CreateVariantArray(0, 2) Set BrowserItems(0) = Browsers.Item("iexplore") Set BrowserItems(1) = Browsers.Item("chrome") Set BrowserItems(2) = Browsers.Item("firefox") browserindex = VarArrayLowBound(BrowserItems, 1) While browserIndex <= VarArrayHighBound(BrowserItems, 1) Call BrowserItems(browserIndex).Run 'Opens the specified URL in a running instance of the specified browser. Call Browsers.CurrentBrowser.Navigate(Project.variables.TestURL&"/dashboard") log.message("browsed to Dashboard") Call Sys.Browser.Page(Project.variables.TestURL&"/dashboard").wait 'Wait till page is existing Do aqutils.Delay(100) Loop until Sys.Browser.Page(Project.variables.TestURL&"/dashboard").Exists log.message("dashboard loaded") ' do stuff Call Aliases.browser.BrowserWindow.Close(5000) Wend SolvedRe: Opening second browser window Fantastic Colin! Thank you very much. Re: Opening second browser window Colin, If it would be possible: could you provide me with some code on how you handle this issue? (I'm using vbscipt, but any code will do, i'm able to translate) It kept me awake part of the night to get this solved.... Thanks in advance!