I am working in TestComplete and have just learned about scripts as a way to make more complex test steps in the TestComplete environment. Because my tests will probably be used in the future, one of my ideas was to make a make a script that could compare the current date with a certain textbox and see whether the two are equal. This would mean that the script always had the current date of the test, rather than a hardcoded value.
Then I thought this: I shouldn’t tie this to a certain object in one test, making only that test continuously relevent, I should rather make this more generic, so I can apply it in multiple tests, or in multiple places in the same test. To do this, I wanted to give my function an argument that would take in a TestComplete object (those things that the Namemapping file is made up of). I don’t know JavaScript at all, but I know that in Java (which is not like JavaScript), you have to Type your arguments, and I didn’t know what to use for my Type.
This is what I have tried so far:
function DateCheck(dateTextObject) {
aqObject.CheckProperty(dateTextObject, "text", cmpEqual, aqDateTime.Today());
}
I am planning for the dateTextObject to be the long NameMapped object that I want to pass in, for example: Aliases.browser.pageLeadMainTestcompletetestDyna.sectionQuickCreateContact.sectionDetails4.textboxDate
When I passed that into my test, however, it gave me an error that told me there was a Type mismatch. I didn’t really think JavaScript used static typing, and that you didn’t have to Type things (again I have barely begun learning about it), so this error was confusing to me.
I would appreciate any help you could give to me about this issue. Thanks!
user25471851 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.