Checking API Status in TestComplete
Introduction I first saw the need to verify the state of an API several years ago with an application that used an address validation API in several of it's operations. If this API was down or did not respond in a timely manor, many of the automated test cases would run and fail. In this case, and in others, I have found that doing a simple call to the API to check the returned status code allowed me to skip, fail or log a warning with a logical message instead of allowing the application to fail with another less direct error message due to the API issue. The aqHttp Object The TestComplete aqHttp object and it's methods are very useful for performing simple checks like this and are also useful for other more complex tasks like leveraging an API to return a test data set or even verifying a certain data is returned prior to running tests against the UI that depend on the data. Sending and Receiving HTTP Requests From Script Tests More Complete API Testing Most proper API testing should be done using a tools like ReadyAPI or SoapUI. Both of these tools will integrate with TestComplete or can be used alone and will provide much more capabilities and automation options. Integration With ReadyAPI and SoapUI Code Example Here I have provided a working example of how to code a Get request using 'aqHttp.CreateRequest' to confirm an API returns a status code of 200 and it will log the returned records. function sendGetRequest() { let resourcePath ="https://restcountries.com/v3.1/all" let resourceQuery = "?fields=name,capital"; let url = resourcePath + resourceQuery; try { // Send GET request let response = aqHttp.CreateRequest("GET", url, false).Send(); // Check for successful response if (response.StatusCode === 200) { // Parse JSON response let allData = JSON.parse(response.Text); Log.Message("Total records received: " + allData.length); // Process each record allData.forEach((record, index) => { Log.Message("Record " + (index + 1) + ": " + JSON.stringify(record)); }); return true; // Send a bool back to the calling function. } else { throw new Error("Failed to fetch data. Status code: " + response.StatusCode); } } catch (error) { Log.Error("Error during request or data processing: " + error.message); } } Enhancements You could accept parameters for the resourcePath and resourceQuery. Parameterize the logging loop run or remove it. Return the JSON to the calling function for use. Perform other tasks based on the return code. Conclusion With the growing use of API calls in desktop applications and the fact that APIs are almost the foundation of any web site checking an API before a test case run is almost a requirement for consistent test runs and good error logging. This small script can bring big rewards to your test runs and reports. Cheers! I hope you find it as useful as I have! If you find my posts helpful drop me a like! 👍 Leave a comment if you want to contribute or have a better solution or an improvement. 😎 Have a great dayProblem with generated data table and keyword test
Dear Community, I have a problem with a created table type project variable. Here is my script, I checked data inside the generated table and everything is OK for the table. function CreateTestExecutionDataTable(){ // Create a table variable if it doesn't exist if(!Project.Variables.VariableExists("TestExecDataTable")) Project.Variables.AddVariable("TestExecDataTable", "Table"); // Get a reference to the variable var t = Project.Variables.VariableByName("TestExecDataTable"); // Add columns to the table t.AddColumn("Test Execution"); t.AddColumn("Environment"); t.AddColumn("Build Type"); t.AddColumn("Team"); // Create rows TestExecutionData.testExecutionList.length-2 t.RowCount = testExecutionList.length-2; Log.Message("Length of the execution table "+t.RowCount) for(let i = 0; i < t.RowCount; i++){ t.$set("Item","Test Execution", i, testExecutionList[i+2]); t.$set("Item","Environment", i, environmentList[i+2] ); t.$set("Item","Build Type",i, buildTypeList[i+2] ); t.$set("Item","Team", i, teamList[i+2]); } } Then I want to integrate a Data driven loop that will perform actions for each item in the table var. The problem occurs when I want to choose some values and perform actions, because I don't see anything. I don't have any idea about how to use this generated table in my keyword test. Does anyone have an idea? Thank you for your help.Solved105Views0likes6CommentsPassing test data randomly to script tests from Excel file
Hello everyone, Have a productive week. I just started playing around with TestComplete so I will around for some time. Thanks in advance for any comments. My question is: I created data by using TestComplete's data generator to an external file. How can I pass this data to my code that I record in script testing? I could not find much things to read in official documentation. RegardsSolved73Views0likes3CommentsGithub Copilot Integration
GitHub Copilot suggests code completions as developers type and turns natural language prompts into coding suggestions based on the project's context and style conventions. One new idea would be having a copilot plugin for testcomplete would increase productivity and coding efficiency URL for reference - https://github.com/features/copilot423Views4likes0CommentsTest steps get disabled automatically when a TestExecute test run fails in Azure pipeline
We have test scripts running in an Azure release pipeline, using the TestComplete adaptor (TestExecute as "preferred test runner"), and Visual Studio Test. We do NOT have the "Rerun failed tests" option in the Visiual Studio Test task enabled. If I have a test script, with all steps enabled in the execution plan, and any of these steps fail - when I log onto the agent virtual machine that has run the tests, I can see that the Execution Plan has all the passed test steps disabled and the failed test steps enabled. I've searched everywhere to find what controls this behavior, but cannot find anything. If a test fails I do not want any changes to the Execution Plan to be made automatically. Please could anyone help advise about this issue? Thank you.26Views0likes0CommentsProperty check point does not work with multiline data in a csv
col1,col2,col3 test1,"test2.1 test2.2 test2.3",test3 A similar to this csv is what I am using in the data loop, and in the "Quoted Text" section I am using ", when I look at the file in that section it displays like this col1,col2,col3 test1,test2.1 test2.2 test2.3",test3 and the property check point is failing Actual Value: "test2.1↴test2.2↴test2.3" Expected Value: "test2.1" Please show me the right path, the guidance, the light.189Views0likes3CommentsCommand line result storage
TestComplete.exe "E:\Projects\abc\abc-web\a-web.pjs" /r /sl /p:Regression /t:"KeywordTests|abc_login" /sl:"E:\Results\new-log.txt" I wrote this, opens TS, runs the Keyword tests abc_login but does not store results in E drive. I looked at the Command line documentation and could not figure it out. I know it`s something small thing that I am missing in the code above. Help is highly appreciated. ThanksSolved177Views0likes1CommentData loop testing
So, I have 100 customers and as you can see in the image above there are 6 files for Customer 1 but there may be 2 files for Customer 2. I did the data looping of Customer number only. How do I make the test that it after it completes with 6 files, it goes back and select Customer 2 and if Customer 2 has 3 files then complete that go to Customer 3 which has 5 files. Thanks166Views0likes2CommentsTestComplete form best practices in a DDT Data Driven Loop
To all. Is there a TestComplete document that shows the best practices to follow when trying to DDT from an excel spreadsheet into a web based form with dropdown fields? I am seeing a high failure rate when trying to DDT in a data loop. Yes, I have made sure all operations are indented that need to be a part of the loop. Yes, I have added delays before and after the problem dropdown box in question. Thank you in advance for your help and guidance. -todd2116Views0likes1Comment