SE Tip : Drag-and-drop one object to another
Hi all, A common challenge in automation is achieving precise drag-and-drop actions, especially when dealing with dynamic or responsive user interfaces. This question comes up regularly in different ways - how do I refine the drag-and-drop action in TestComplete? TestComplete's built-in Drag action is designed to drag a specific Alias object from a given point to another point, but at a pixel offset (i.e. drag Alias....Button by X/Y pixels). While useful as a "jumping off point", this approach can be problematic for obvious reasons (Dynamic UIs, changing screen resolutions, inconsistent offsets) leading to brittle tests. Fortunately, TestComplete method parameters offer a high degree of customisation. By evaluating and utilising exposed properties like ScreenTop/ScreenLeft, we can create more robust and adaptable drag-and-drop actions. This allows us to instead dynamically reference the coordinates of a target object, or better still use exposed values in simple calculations, like figuring out the offset value for the Drag action. This Python script example calculates the offset using the commonScreenTop and ScreenLeft positions of both objects then passes the difference to the Drag action, allowing us to drag one given object to another given object with much more flexibility : def dragToObject(clientObj, targetObj): # Using ScreenLeft property to drag horizontally; ScreenTop for vertical fromObjectTop = aqObject.GetPropertyValue(clientObj, "ScreenTop") fromObjectLeft = aqObject.GetPropertyValue(clientObj, "ScreenLeft") toObjectTop = aqObject.GetPropertyValue(targetObj, "ScreenTop") toObjectLeft = aqObject.GetPropertyValue(targetObj, "ScreenLeft") dragY = toObjectTop-fromObjectTop dragX = toObjectLeft-fromObjectLeft Log.Message("Dragging "+aqConvert.IntToStr(dragX)+"px horizontally and"+aqConvert.IntToStr(dragY)+"px vertically") clientObj.Drag(-1, -1, dragX, dragY) You can then even utilise this in your KeywordTests, by changing the input parameter Mode to Onscreen Object, which enables the Object Picker : Now you have a way to drag one object to another - for example a value into a table? Hope this gets the creative juices going - can you think of other ways you might handle dynamic values in other Action methods? Regards, Mike TestComplete Solutions Engineer37Views3likes0CommentsChecking until a window doesn't exist
Is there any way to check until a window doesn't exist. An inverse .WaitWindow()? Alternatively, is there a version of .Exists() that just returns bool? I've looked around forums and tried implementing this myself, but haven't found anything that works. I'm using TC with Python. I set exceptions to not panic/exit early in TC, but .Exists() still does for some reason, even when caught.105Views0likes8CommentsName Mapping not working on remote browser
The name mapping and test cases work fine on local browsers, but would complain about page or object not found when running headless remote browsers and in parallel testing. I have the following setup for browser name mapping: For headless setup I have: server = "localhost" capabilities = { "browserName": "chrome", "headless" : "true", "screenResolution": "1920x1080", "platform" : "Headless", "record_video": "true" } Browsers.RemoteItem[server, capabilities].Run(url) Is this the correct way to work with name mapping on headless browser?932Views0likes15CommentsMy opened window from a button click close immediately
I am trying to click on a button inside a popup that will open a window to browse files, but when TestComplete click the button when running the Keyword Test, what happen is the following: the popup containing the button clicked close (as it should) and the window to browse files open and close immediately. I am trying to do this in a python script that is executed in the Keyword Test. I tried ClickButton, Click, DoubleClick, but it all do the same. The button opening the window is in WPF. If someone have an idea to keep the window open when it is opened by testcomplete, I would be thankful.Solved48Views0likes4CommentsConnecting to a SQL Server database using Integrated Security from JavaScript
I have a BDD test. One of the step definitions connects to SQL Server database and fetches some data. I use JavaScript. This the JavaScript code I have. The connection used Integrated Security, so no need to give user id and password var connection=ADO.CreateADOConnection(); connection.ConnectionString="Provider=SQLOLEDB;Data Source=<datasource>;Initial Catalog=<database>;Integrated Security=SSPI"; connection.Open(); connection.Open() is throwing up a message box asking for user id and password. See the attached screenshot. The above connection string works fine with Database Tables (Stores=>DbTable). See the attached screenshot. Does anyone has code sample to connect to SQL database using integration security.24Views0likes1CommentHow to add external files to a project?
Hi everyone, I'm new to TestComplete and currently struggling with something that I believe should be fairly straightforward. I’m trying to add a test-data folder within my TestComplete project and include a JSON file in it. However, when I attempt to create a new file, I only see options for default project items (events, stores, scenarios, etc.), and there doesn’t seem to be an option to add external files like JSON directly. The workaround I’ve found is to add the file through Windows Explorer, and then from TestComplete use the add existing item option to place the file under the test-data folder, but I would expect there to be a way to create the file directly in TestComplete. What is the correct approach for including external files in specific project locations? Is there a better way to manage these files within TestComplete? Thanks for any insights!Solved66Views0likes10CommentsRuntimeErrors 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?129Views1like8CommentsTestComplete cannot find chrome webdriver
Hello, I am trying to get TestComplete to run headless tests. I am following this guidehttps://support.smartbear.com/testcomplete/docs/app-testing/web/supported-browsers/headless.html#localand I am running into the issue that TestComplete cannot download/see the needed WebDriver. This is the JavaScript used in the guide. function Test_Chrome_Headless() { var server = "localhost"; var capabilities = { "browserName": "chrome", "screenResolution": "1920x1080" }; var url = "myurl"; Browsers.RemoteItem(server, capabilities).Run(url); } I downloaded the chrome driver manually and created the path as shown above. But even with the driver in the correct location he cannot seem to open it. When I try to open the driver myself, it works. Does anyone have an idea what I am doing wrong? Kind regards, Luuk584Views0likes4Comments