Pro-Tip: Populating an array in a JScript script extension and using the array in JavaScript
I'm writing this post not to report a problem or to ask a question but simply to pass along some information to save others the headache I gave myself today. I should have realized my mistake a lot sooner than I did but, in the meantime, I learned something valuable about debugging a script extension and one of the "gotchas" that you may run into. Scenario: I wanted to build a runtime object in a script extension that, upon retrieving some data from a datasource, would populate an array that is a property of the script extension. I then wanted to be able to access and iterate through that array in various projects. The script extension is built using JScript and the projects are written in JavaScript (perhaps some of you already see where this is going). Extension: Here is a simple mock up of what is in the extension. It's a bit more involved than this but, for illustration purposes, I've simplified this down to the essentials var myArray = []; function getMyArray() { //This is the "get" routine for getting the property for my runtime object return myArray; } function populateArray() { //This is where the DDT object is created, run through, etc, to get my data. For the purpose of the illustration, I'm simply hardcoding a for loop to populate the array with some objects for(var i=0;i < 10;i++) { myArray[i] = {property1: 'Value1', property2: 'Value2'}; } } Now, when I have this code loaded up into TestComplete in a JScript project and throw some watches on the variables, I see my array populate and I end up with a 10 element array, each element being an object with the two indicated properties and values. Using the Extension: So, I encapsulate that in my script extension, drop it into the appropriate folder, install it in TestComplete and attempt to run the following code in a JavaScript project function iterateArray() { for(var i = 0; i < extension.myArray.length; i++) { Log.Message('Object ' + i + ' property 1 value: ' + extension.myArray[i].property1); } } Here's where I get the problem... I get an error that property1 is not a valid property of "undefined". Doing a watch, I see that my array is populated and it has the correct length, but instead of each element being an object, each element is marked as "undefined". What gives?!?! Well... here's why... JavaScript, as it is implemented in TestComplete,has some issues with working with the values of indexed properties of objects. While, generally speaking, if I created an array in JavaScript and worked with that JavaScript native array in my JavaScript project, I wouldn't have this issue. However, it appears that, because the JScript array is encapsulated in another object and is, therefore, an object with an indexed property, I need to use a different methodology for retrieving the values. Solution: Once I realized this, I modified my code in my JavaScript project as such: function iterateArray() { var currentObject for(var i = 0; i < extension.myArray.length; i++) { currentObject = extension.myArray.$get(aqConvert.IntToStr(i)); Log.Message('Object ' + i + ' property 1 value: ' + currentObject.property1); } And voila! it works. Now, if I was using the extension in a JScript project, this wouldn't be a problem. But, as it is, because of JavaScripts peculiarities, this was the solution I ended up with. Of course, there's probably all sorts of other ways of doing this... but this is how I got rid of my headache today.1.4KViews4likes0CommentsTestComplete Framework
For those of you who attended the SmartBear Academy 301 on October 18th, I've made a couple of relatively minor changes to the framework I presented and the script extensions I created for them. If you are interested, you can download the framework code, the extensions, and the samples at https://bitbucket.org/tristaanogre/tabledrivenframework/downloads. Please feel free to message me any questions or such on this. Again, this is a Creative Commons licensed thingie so feel free to use itunder the license terms.1.9KViews4likes0CommentsBoost TestComplete code autoCompletion
Has anyone ever tried to write their intellisense plug-in for e.g. WebStorm with TestComplete interface structure? or vice versa through "script extension" and their available code completion read files and create a 'better' intellisense than it is now in TestComplete IDE? Additional question. Have you encountered somewhere in the files or in the online sources with the object interface declaration currently available in the Intellisense TestComplete IDE?Solved2.9KViews3likes7CommentsTestComplete JIRA Script Extension
Hi everyone, With the release of TestComplete 14.4, Smartbear has released a new JIRA script extension, so that we can use it in more ways than just the toolbar option that we see in our test logs. It can be downloaded in the Smartbear github link below, following the instructions as described in the readme file. This may be old news to alot of you by now as well. https://github.com/SmartBear/testcomplete-jira-extension I think this is a great step forward in creating some more elegant workflows with JIRA, which has sort of become the de facto issue tracking software for many agile organizations. We can see all of the methods that are available here within the docs page: https://support.smartbear.com/testcomplete/docs/reference/program-objects/jira/login.html With this new script extension, this means we can elegantly and automatically create new issues, and update old ones, possibly even using event handlers to update the relevant issues with more context like the visually pleasing mht files. Recently though, I came across a question of whether or not we could move resolution statuses (i.e backlog, selected for development, done, etc.) based on those same type of triggers (i.e onLogError, or conditionally based on logerrorcount). After a quick google search, it seems that jira workflow statuses aren't fields that can be set; they need to be transitioned. This meant that we couldnt use our new jira script extension, and the setField or setFieldJson methods to do just that. Thinking a little bit further about this, it makes sense, because why have a kanban board, unless we want to visually confirm some facts about our issues and physically move them across the various stages of development. Also, we probably don't want our issues to move drastically via automation (my worst nightmare would be waking up to 40 emails from JIRA telling me that all of my issues changed resolution statuses, and later find out that these moves were mistakenly triggered via a CI framework because of a bug in a one of the systems under test) The only way to "transition" the workflow statuses seems to be through accessing JIRA's api. There are certainly endpoints that do this for us. (along with some external libraries aka pip install jira) But as for whether or not we should be doing that? I dont know. ----and now moving this to our tc ide3.2KViews2likes5CommentsError when executing Devops pipeline
I'm trying to run a pipeline that runs a test by test execute, when running the pipeline it opens testExecute but it's not opening the project. Here is the path where my project is: C:\agent_work\1\s\TestComplete\BusinessAutomacao\BusinessAutomacao.pjs Project name:BusinessCSAutomacao Now follow the Pipeline I created: trigger: - master pool: name: TesteAutomatizado steps: - task: VisualStudioTestPlatformInstaller@1 inputs: packageFeedSelector: 'nugetOrg' versionSelector: 'latestPreRelease' - task: InstallTestCompleteAdapter@1 inputs: accessKey: 'keyfake' logsLevel: '0' - task: VSTest@2 inputs: testSelector: 'testAssemblies' testAssemblyVer2: '**\TestComplete\BusinessAutomacao\BusinessAutomacao.pjs' searchFolder: '$(System.DefaultWorkingDirectory)' testFiltercriteria: 'Project=BusinessCSAutomacao' vsTestVersion: 'toolsInstaller' In this example I didn't pass the accessKey I'm using But when running the pipeline, the following error occurs: Does anyone know how to resolve?817Views1like13CommentsMigrate from TestComplete v14 to v15, ES5 to ES6
Dear TestComplete Users, Am trying to move from v14 to v15 and start using ES6 instead of ES5. I have a question which may be obvious to you, but am unable to work around. Looking forward to suggestions. I installed v15 and tried a sample script to confirm it supports ES6. It does! See picture below. Next I opened a project that always worked well in v14. It worked in v15 too. But when I try to run the same code in the picture above in a new or existing script, it doesn't work. What am I missing? Is there a project setting? If you have other experiences moving to ES6, please do share.Solved403Views1like2CommentsCheck if object exists
Hello everyone, I want to create a function which returns true if an object exist and is visible on screen without waiting for the full timeout period. Here is the function I tried to create: def isObjectVisible(object): name = object.Name parent = object.Parent if parent.WaitChild(name, 100).Exists: return object.Visible return False The issue I encountered is that accessing the name property of the object causes the test to wait 10 seconds for the name property I there a way to achieve this result? I can create another function which takes the parent and child name as parameter but that is cumbersome.Solved1.4KViews1like5CommentsTestComplete IntelliJ Plugin still alive somewhere?
Hey folks, we are currently running a TestComplete pilot and we mostly are scripting our tests. We are currently struggling a bit with the auto-completion and in general with the integration of IntelliJ in the workflow with TestComplete. We know there has been a plugin in the past but we are not able to find it anymore. Does someone has experience with it? Also the plugin in VSCode doesn't seem to work great..454Views1like3Comments