How to import a javascript class and extend it in another script unit
Hi I am trying to use two Javascript projects - and export a class defined in one to be extended (inherited) in another. The example herehttps://community.smartbear.com/t5/TestComplete-General-Discussions/how-to-import-a-javascript-class/m-p/149161#M27448 shows how to use require and create an instance of the class. However, I would like to inherit the class (ES6) and define or override the methods. I was able to do this using prototype based inheritance (ES3). But unable to do this using ES6 terms. The "import" keyword usage shows syntax error "Unexpected token import". If I use require, then I cannot actually use it with extends e.g. (Note that I have shared the Parent.js into the project) //In Parent.js class ParentApp { constructor(x) { this.name = x; } } module.exports = { ParentApp: ParentApp } //In Child.js var parent = require("Parent") class Child extends parent.ParentApp { constructor(y, z) { super(y); this.age = z; } } Here the "parent.Parent" is not working. And I can't use import keyword. (Note that sometimes having the script name same as class name seems to cause issues and that's why I use Parent and ParentApp to differentiate) So how do I do this? Is ES6 fully suppported in Test Complete 14?Solved16KViews0likes6CommentsExample of evaluateJavascript() usage in Webview for Smartbearbrowser on Android device
Mobile.Device().Process("*SmartBearBrowser").FindChild("ObjectType", "WebView", 2).evaluateJavascript("(function() { return null; })();", new ValueCallback<String>() { @Override public void onReceiveValue(String s) { Log.d("LogName", s); // Prints the string 'null' NOT Java null } }); The above example doesn't seem to work (Error 100). I also can't create ValueCallback's in generell ... Mobile.Device().Process("*SmartBearBrowser").FindChild("ObjectType", "WebView", 2).evaluateJavascript(script, ???) Is were an Example on how to write the Statemant correctly in Testcomplete ?4.3KViews0likes1CommentSetup and Tear down, as well as Try Catch questions.
Hello, I am fairly new to TestComplete, so please bear with me. I am using TestComplete to test a windows application. I am more used to the NUnit side of things. In NUnit, you can have setup and teardown functions that will run before any test as well as after any test, even if there is an failure in that test. Does TestComplete have this kind of functionality? If it does not, is there any easy work around to always be in a consistent state for each test? Also, I am trying a try catch block using JavaScript in TestComplete. Basically to try to close my app, and if it cannot, catch by writing to the log. My problem is, if inside the try look, there is an error, the test just stops. So, I am unsure why it just doesnt kick to the catch, and move on like nothing is wrong. Is this expected, and if so, what is the point of try catches in TestComplete. Thanks for all of your time.3.1KViews0likes8Commentsnot able to use Drag method
Hi, I am trying to drag and drop an item from one panel to another. When i record and play the script, it works fine. But when i try to use the Drag method in my script (using javascript), it says Drag is not a function. What is possible wrong here ? Record script - let page = Aliases.pageShoppingPortal; page.panel.Drag(134, 23, 26, 182); Javascript - let memberdrag = page.contentDocument.getElementsByClassName("name cdk-drag"); memberdrag.item(1).Drag(134, 23, 26, 182);Solved2.8KViews0likes18CommentsTestComplete javascript implementation of an Dictionary object bugged.
The code example they give for the new "getActiveXObject("Scripting.Dictionary")" implementation of a dictionary is as follows: function DictionaryDemo() { let d = getActiveXObject("Scripting.Dictionary"); // Add keys and items. d.Add("a", "Alphabet"); d.Add("b", "Book"); d.Add("c", "Coffee"); // Get the item by key. var s = d.Item("c"); Log.Message(s); // Assign a new item to the same key. d.Item("c") = "Cookie"; s = d.Item("c"); Log.Message(s); // Assign a new key to the same item. d.Key("c") = "Co"; // Remove second pair. d.Remove("b"); if (d.Exists("b")) Log.Message("The pair exists.") else Log.Message("The pair does not exist.") } This code breaks in a couple of places. The line 'd.Item("c") = "Cookie";' gives the following error: JavaScript runtime error. ReferenceError: Invalid left-hand side in assignment. The line 'd.Key("c") = "Co";' gives the following error: JavaScript runtime error. Error: Member not found.Solved2.2KViews0likes4CommentsClicking a span button
Hi, I have a span button on the webpage with this code <span class="ui-autocomplete-icon searchmode" id="Schedule-00-Row471b178a-49c2-499d-828e-f0cac7690899E-Icon"></span> I use this Javascript code in TC to point to that span button Page = Sys.Browser('*').Page("www.myweb.com"); var button = page.QuerySelector("span.searchmode"); Var button successfully find that span button. But when I do this button.ClickButton(); or button.Click(); TC complains that TypeError button.ClickButton is not a function or TypeError button.Click is not a function wondering why TC cannot click that button:mansad: Thanks.2.2KViews0likes3CommentsHow to execute JavaScript (JS) in TestComplete during Web App testing?
I have used Selenium WebDriver. In some cases it needs to use JS. For example for hidden field, it needs to use JS. I have done this in Selenium WebDriver usingJavascriptExecutor interface. Is it possible to use JS in TestComplete? If yes, how?1.8KViews0likes1CommentEnum of possible options for TestComplete Element not showing up in Autocomplete / Code Completion
I have a question, I have a small script used to select values for different controls on a webpage. Because these values are finite, they are a perfect candidate for an Enum, so as to reduce the possibility of someone having a typo in text, and also to properly reference values in case they need to change in the future. Please see what I have below: const assuranceLevel = Object.freeze({ LOW: {value: 1, name: ' Low '}, MODERATE: {value: 2, name: ' Moderate '}, HIGH: {value: 3, name: ' High '}, VERY_HIGH: {value: 4, name: ' Very High '} }); function locateButtonGroup (buttonGroupTitleString) { return page.FindChildByXPath("//h4[text()='" + buttonGroupTitleString + "']/parent::div"); } function selectLevel(buttonGroupElement, assuranceLevel) { buttonGroupElement.FindChildByXPath("./descendant::label[contains(text(), '" + assuranceLevel.name + "')]").Click(); } function testPage() { selectLevel(locateButtonGroup("Overall SAL"), assuranceLevel.VERY_HIGH); selectLevel(locateButtonGroup("Confidentiality"), assuranceLevel.MODERATE); selectLevel(locateButtonGroup("Integrity"), assuranceLevel.VERY_HIGH); selectLevel(locateButtonGroup("Availability"), assuranceLevel.MODERATE); } This works as expected, and I can use one of the "assuranceLevel" options to constrain my choices to valid inputs. However, when typing assuranceLevel, when I hit the ".", I would expect an autocomplete window to come up, allowing me to select one of the viable options. That does not happen, and I have to type out the option. This defeats the entire purpose of using the enum in the first place, as the possibilities for typos still exist. It's frustrating that VSCode and sublime text editor can do this just fine, but TestComplete can't. Is there any way to get TestComplete to display options from enums in autocomplete?Solved1.7KViews0likes7CommentsDDT.CurrentDriver' is null or not an object
i keep getting this error on my testing using javascript. I have looked all materials within smart bear...not sure what else to do. This is what i have so far. function DriveMyTest() { var mycsv; mycsv = DDT.CSVDriver("C:\\TestComplete\Book1.csv"); mycsv.DriveMethod("ScriptTest.Test1"); } function Test1() { textbox = panel.textboxClaimLabOrderId; textbox.Click(72, 1); textbox.SetText(DDT.CurrentDriver.Value("textboxClaimLabOrderId")); }Solved1.6KViews0likes5CommentsInteracting with HTML DOM objects via javascript or Ajax in TC 14
I'm new to testcomplete. We have an area in our web app that is extremely difficult for testcomplete recorder to understand. We have a hidden ul that become un-hidden on a button click. Each list element has an input checkbox. I'm attempting to select all items in the list and check each item. The recorder is struggling so I thought we could just inject some javascript or ajax to make it happen. In our selenium/.NET C# solution I just executed some ajax like so:$("div[aria-checked*= 'false'] span.dx-checkbox-icon").click() I would like to execute something similar. Below is an example of the hidden ul. <ul class="dx-treeview-node-container" role="group"> <li class="dx-treeview-node dx-treeview-item-with-checkbox dx-treeview-node-is-leaf" data-item-id="0" role="treeitem" aria-label="Period Index" aria-expanded="true" aria-level="1" aria-selected="false"> <div role="checkbox" class="dx-checkbox dx-widget" aria-checked="false"> <input type="hidden" value="false"> <div class="dx-checkbox-container"> <span class="dx-checkbox-icon"></span> </div> </div> <div class="dx-item dx-treeview-item" aria-selected="false"> <div class="dx-item-content dx-treeview-item-content"> <span>Period Index</span> </div> </div> </li> <li class="dx-treeview-node dx-treeview-item-with-checkbox dx-treeview-node-is-leaf" data-item-id="1" role="treeitem" aria-label="Period Begin" aria-expanded="true" aria-level="1" aria-selected="false"> <div role="checkbox" class="dx-checkbox dx-widget" aria-checked="false"> <input type="hidden" value="false"> <div class="dx-checkbox-container"> <span class="dx-checkbox-icon"></span> </div> </div> <div class="dx-item dx-treeview-item" aria-selected="false"> <div class="dx-item-content dx-treeview-item-content"> <span>Period Begin</span> </div> </div> </li> </ul> There are about 45 items in the list. My goal is to add a short script snippet to a keyword test to set the inputs to 'checked'. Any help would be great. thanks!Solved1.4KViews0likes3Comments