Append/Replace Record Script Options?
There used to be options when right-clicking on a script function to either append to or replace the current script. But I don't see those anymore. Am I missing a setting somewhere, or were they removed in the most recent update (15.75)?Solved147Views0likes16CommentsChecking 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 day53Views0likes0CommentsFindAll returns only one (first) element
Hi guys, I'm experiencing a weird problem. I have a mapped element, from which I need to get an array of elements. If tested in chrome/edge dev mode, the xpath of mapped element happily returns number of elements. But FindAll returns only one (first) element. Here is the code I'm using: function CompareElementsWithRefJSON(createNewRefFiles, setElementFlag, headerInputs, tabInputs, autocompleteMenu, selectPopUpMenu, tabsData, filePath) { let headerItems = headerInputs.FindAll('type','*',5000); headerItems = headerItems.toArray(); ... } I have a workaround, using FindElements, which works OK, but I don't like it, because it's unnecessary complicated: function CompareElementsWithRefJSON(createNewRefFiles, setElementFlag, headerInputs, tabInputs, autocompleteMenu, selectPopUpMenu, tabsData, filePath) { let formInputsXpath = GetXpathFromAlias(headerInputs); // This returns xpath of mapped alias object let headerParent = headerInputs.Parent; // Get parent element let headerItems = headerParent.FindElements(formInputsXpath); // Returns array of elements. Works OK. ... } So, any idea why FindAll returns just one element? BTW, it does not matter what PropName I use as the first parameter. The result is the same. Always just one element.145Views0likes19CommentsIs there any way to get code completion to function when using classes?
Hi all, I'm working a little with classes inside of TC, and have have been rubbing up against an issue with code completion (intellisense) not working. If I have the two blocks of code in different .js files; class foo { constructor(panel) { this.panel = panel; } } function LogMessage(){ Log.Message(`This Is a Logged Message from the parent class`) } module.exports = {Foo: Foo} const foo = require("Foo"); class Bar extends Foo.Foo{ constructor(panel){ super(panel); } } function secondClassFunction(){ Log.Message(`This is the child class`) } module.exports = {Bar:Bar} And then in a third .js file, have another code block calling the 'Bar' class like the following var Bar= require("Bar"); function FunctionName(){ const x = new Bar.Bar(`panel`); } Typing 'x.' won't generate any intellisense prompts to appear. Has anyone seen this before \ is there a solution \ work around? I understand there might be a few different ways to implement inheritance (which is my ultimate goal, since Bar is a child of Foo), so if anyone has any suggestions for rewriting this that might help, the feedback would be appreciated. Thanks, DanSolved70Views0likes5CommentsJUnit Export Does Not Include Execution Time and Warnings in XML File
When using the method Log.SaveResultsAs(Project.Variables.FileLog, lsJUnit), the generated XML file does not include critical information shown in the TestComplete summary, such as the total execution time and the number of warnings.30Views0likes1CommentgetGlobal returned NULL error after upgrade
Using OCR capability provided via Intelligent Quality add-on to test a LabView application. TestComplete python scripts were working fine on TestComplete ver. 15.69. Upgraded to ver. 15.73 and am now intermittently hitting the following error: Run test script 1 - this automatically invokes application and script is run successfully. Application is left running. Run test script 2 - script begins but then immediately hits "Python runtime error. SystemError: <built-in function getGlobal> returned NULL without setting an exception. The error occurs on a simple variable assignment (e.g., "map_sel_pref": spNone) within a python dictionary. The problem appears to be in identifying the spNone (which is one of the SelectionPreference constants associated with the OCR BlockByText() method). If I shut down the application and then re-run test script 2, the test script will invoke the application and test script 2 will be successful. This does not happen consistently -- there are cases where steps 1 and 2 above run fine without error. In cases where I hit the error, I can successfully access the NameMapping objects -- that is, TestComplete can identify the application after test script 1 completes and the application is left running. Since the SelectionPreference parameter is simply an integer, I could change my code from "map_sel_pref": spNone to something like "map_sel_pref": -1 if I knew the constant values, but I don't believe that is documented anywhere. More importantly, not sure why this has become a problem with the latest update. Any suggestions on fixing/resolving this?48Views0likes1CommentCan TC automation be done through remote desktop connection of Windows?
Hi there: My case is as below: 1 Use TC open remote desktop connection of Windows, then input IP, click connect 2 Switch to remote desktop of target server, then do some operation on target app of target server 3 back to local server do next step operation Can TC do thin kind of work like I said? If so, how can I write the script to do like this? I really appreciate any help you can provide.Solved78Views0likes7CommentsRuntimeErrors after upgrading to 15.68.8.7
Hello, I recently upgraded to the latest version of TestComplete, and unfortunately, I'm experiencing issues. I'm still facing a RuntimeError originating from TestComplete's native functions (I'm using it with Python scripts). The errors occur with functions like Log.Message, Log.AppendFolder, and others. However, the problem is quite random, as it's not always the same line of code that fails. As a result, I'm unable to execute any tests at the moment and will need to downgrade to the previous version. Is anyone facing this problem as well?320Views2likes12CommentsHow to read a range of excel cells as List or List of List Python using Excel OLE Objects?
I am migrating the existing vba code to py. so we are using the ole object to read excel like below. can someone help to read range of cells, the documentation points to read only a single value instead of range. https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/sys/oleobject-property-sys-object.html Even i tried to download additional samples and that also don't have any range function. i need a good documentaion for excel using ole Excel = Sys.OleObject["Excel.Application"] Excel.Workbooks.Open("C:\\MyFile.xlsx") RowCount = Excel.ActiveSheet.UsedRange.Rows.Count ColumnCount = Excel.ActiveSheet.UsedRange.Columns.Count for i in range(1, RowCount + 1): s = ""; for j in range(1, ColumnCount + 1): ## Is there anyway to read range or all content of the sheet to list of list? s = s + VarToString(Excel.Cells.Item[i, j]) + '\r\n' Log.Message("Row: " + VarToString(i), s); Excel.Quit();Solved1.3KViews0likes8CommentsHow To: Read data from the Windows Registry
Hello all, I have recently learned how to retrieve data from the Windows registry in JavaScript test units. I am using this to return the OS information and application path information. This is very useful when added to the EventControl_OnStartTest event code. This will allow you to return OS information and other needed data at each test run. Some test management systems may provide this information for you or it may be logged in the in data produced in a pipeline run. This will embed the information directly into your test log. SmartBear KB Links: Storages Object Storages Object Methods Storages.Registry Method Section Object Get SubSection Method This bit of code will return the Product Name and Current Build from the registry. This location may vary between OS's so you will want to check this with RegEdit. let Section = Storages.Registry("SOFTWARE\\Microsoft\\Windows NT", HKEY_LOCAL_MACHINE); let regKeyString = Section.GetSubSection("CurrentVersion").Name; let productIdString = Storages.Registry(regKeyString, HKEY_LOCAL_MACHINE, 1, true).GetOption("ProductName", ""); let currentBuildString = Storages.Registry(regKeyString, HKEY_LOCAL_MACHINE, 1, true).GetOption("CurrentBuild", ""); Log.Message("Windows Version: " + productIdString + " Build: " + currentBuildString ) I have also found the need to find and set an application path and work folder in the project TestedApp for running through a pipeline because the pipeline deploys the application to a non-standard path. let Section = Storages.Registry("SOFTWARE\\WOW6432Node\\<_yourSectionName>\\", HKEY_LOCAL_MACHINE); let regKey = Section.GetSubSection(<_yourSubSectionName>).Name; let Path = Storages.Registry(regKey, HKEY_LOCAL_MACHINE, 0, true).GetOption("", ""); let WorkFolder = Storages.Registry(regKey, HKEY_LOCAL_MACHINE, 0, true).GetOption("Path", ""); let appIndex = TestedApps.Find(<_yourAppName>); if (appIndex >= 0){ if(TestedApps.Items(<_yourAppName>).Path != Path){ TestedApps.Items(<_yourAppName>).Path = Path } if(TestedApps.Items(<_yourAppName>).WorkFolder != WorkFolder){ TestedApps.Items(<_yourAppName>).Params.ActiveParams.WorkFolder = WorkFolder; } } else{ Log.Error("TestedApp " + <_yourAppName> + " does not Exist.") Runner.Stop(true); } I hope you find these links and code examples as useful as I have! Have a great day!86Views0likes0Comments