Contributions
Re: trouble accessing treeview item count property
OK so feeling stupid. Replacing treeView1 with WinFormsObject("treeView1") works. Why? def miscdriver(): editMultQueryDialog = Aliases.ACMConfig.FormCustomPropertyQuery if editMultQueryDialog.treeView1.Enabled is False: editMultQueryDialog.toolStrip1.ClickItem("Add") else: #deselect all nodes at root level tree = editMultQueryDialog.WinFormsObject("treeView1") treeitems = tree.wItems treeitemcount = treeitems.Count for itemindex in range(0, treeitemcount): if editMultQueryDialog.WinFormsObject("treeView1").wItems.Item[itemindex].Checked is True: editMultQueryDialog.WinFormsObject("treeView1").wItems.Item[itemindex].Check(cbUnchecked)1.2KViews0likes1Commenttrouble accessing treeview item count property
So I have this Python code and I am trying to get the item count of aSystem.Windows.Forms.TreeView: def miscdriver(): editMultQueryDialog = Aliases.ACMConfig.FormCustomPropertyQuery if editMultQueryDialog.treeView1.Enabled is False: editMultQueryDialog.toolStrip1.ClickItem("Add") else: #deselect all nodes at root level tree = editMultQueryDialog.treeView1 treeitems = tree.wItems #this is line 897 treeitemcount = treeitems.Count for itemindex in range(0, treeitemcount): if editMultQueryDialog.treeView1.wItems.Item[itemindex].Checked is True: editMultQueryDialog.treeView1.wItems.Item[itemindex].Check(cbUnchecked) TC12 consistently throws this error on the line 'tree.wItems': AttributeError The object does not support this property or method. Error location: Unit: "ACM_EvalTests\ACM\Script\ConfigureObjectHelper" Line: 897 Column: 1. AttributeError The object does not support this property or method. Error location: Unit: "ACM_EvalTests\ACM\Script\ConfigureObjectHelper" Line: 897 Column: 1. If I go into Object Spy I can select the treeview and drill down into the item count property with no issue: Aliases.ACMConfig.FormCustomPropertyQuery.WinFormsObject("treeView1").wItems.Count Suggestions on resolving this?1.2KViews0likes2CommentsRe: Pop Up Halts Execution
Suggestion....I would look at WaitWinFormsObject and Exist property rather than using 'Delay'. You specify an object to wait on and how long you want to wait for it before timing out. May reduce the time required for your test to execute and make it more reliable. You can also use FindChild to find controls inside your forms without long paths that may be brittle. Example (in Python but same ideas apply)... if Aliases.YourApp.WaitWinFormsObject("FormName", 10000).Exists: expectedForm = Aliases.YourApp.WinFormsObject("FormName") controlInForm = expectedForm.FindChild("WinFormsControlName", "myControl", 10) controlInForm.ClickItem(nameOfItemInControl)1.5KViews1like1CommentRe: TCP/IP client example in JScript; how to send HEX values in bytearray?
Hmm looks like you are calling a function that is inside of a class. Try taking the function out of the class and see if it works. See here: https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/calling-from-dll/known-limitations.html "Only standalone exported routines can be called from TestComplete tests. There is no way to call methods of exported classes."3.7KViews0likes1CommentRe: TCP/IP client example in JScript; how to send HEX values in bytearray?
I'm not familiar with Jscript...but you're calling .NET functions anyway so it doesn't really matter what the language is. I think its a logic problem not a language problem. I found this on stackoverflow which is doing something similar.... http://stackoverflow.com/questions/25129402/how-to-convert-ascii-to-hexdecimal-in-vb-net byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str) For i As Integer = 0 To byteArray.Length - 1 hexNumbers.Append(byteArray(i).ToString("x")) Next ^The lines after GetBytes are the interesting part. I think your code isn't working because the output from GetBytes is not formatted in hexadecimal which is likely what the function you are passing it too to send the data through the socket is expecting. Try formatting the data like they do above with ToString("x"). You'll have to research that to find an equivalent in Jscript. Something to follow up anyway. One more thing...you are familiar with VB.NET...if you can't get JScript to do what you want DIRECTLY you can always write your code to do this in VB.NET, compile it into a DLL, then call the DLL to do what you want from JScript in TestComplete.3.7KViews0likes6CommentsRe: how to best manage large numbers of controls that you have to set?
Yeah I only use a fixed alias for navigating through sub tabs or manipulating the UI in order to get the desired control on-screen. Kind of got lazy there. For setting the controls (example SetTextBox) my code looks like this... def setTextBox(tbRef, newValue, altref=None): rootref = Aliases.ACMConfig.frmMain.panelControl1.superTabControl1.suptabConfiguration.userControlConfiguration1.toolStripContainer2.ToolStripContentPanel.tabObjects.acmObjectView if altref == None: tbhandle = rootref.FindChild("WinFormsControlName", tbRef, 2000) else: tbhandle = altref.FindChild("WinFormsControlName", tbRef, 2000) bsList = ["[BS]"] * len(tbhandle.wText) tbhandle.Keys("[End]%s" % "".join(bsList)) tbhandle.Keys(newValue) If the control (the name is specified in the value for the 'formprop' key) happens to be a child of rootref alias then I don't pass in 'altref', if it is not, the I pass in a alias that I can search into. Its the only way I could do it without the code turning into a giant mushroom cloud. :)1KViews0likes1Commenthow to best manage large numbers of controls that you have to set?
At my organization I use TestComplete Python scripts to automate setting large numbers nested of controls (check boxes, textboxes, drop down combo boxes, etc) in Windows Forms. In one case there is up to 1800 controls on a single page. Usually there is a combination of drop down boxes and tabs that make the controls visible or not and let the user have a sane experience. My question is, how do other people at other organizations manage large numbers of control and map out settings like in that scenario where there are over a 1000 settings on a form and a dozen or more forms? After a lot of experimentation, my solution is below...what are other peoples? It works but it isn't perfect. I make a function that maps every setting for a given form. This function takes the new settings to use and the name of the object it works on as arguments. Then I re-use the same function (I call it) to test different test cases with different objects of the same type. One tab on such a simple form looks like this (some of it obfuscated): I have this code to map the settings for this one tab (again some of it obfuscated): def mapBlah(objname, propvalueDict): propfuncBlahTabDict = { 'RBE Init Message' : {'func' : setCheckBox, 'formprop' : "Prop_blah1", 'tab': "RBE"}, 'RBE Poll Interval' : {'func' : setComboBox, 'formprop' : "Prop_blah2", 'tab': "RBE"}, 'RBE Poll Priority' : {'func' : setComboBox, 'formprop' : "Prop_blah3", 'tab': "RBE"}, 'Primary RBE Scan Rate' : {'func' : setTextBox, 'formprop' : "Prop_blah4", 'tab': "RBE", 'navfunc' : [clickConfigSubTab], 'navfuncargs' : [["Primary", Aliases.blatApp.blahTab.WinFormsObject("tabPage7").WinFormsObject("tabPriSec")]]}, 'Primary RBE Scan Slice' : {'func' : setTextBox, 'formprop' : "Prop_blah5", 'tab': "RBE", 'navfunc' : [clickConfigSubTab], 'navfuncargs' : [["Primary", Aliases.blatApp.blahTab.WinFormsObject("tabPage7").WinFormsObject("tabPriSec")]]}, 'Primary RBE Timeout' : {'func' : setTextBox, 'formprop' : "Prop_blah6", 'tab': "RBE", 'navfunc' : [clickConfigSubTab], 'navfuncargs' : [["Primary", Aliases.blatApp.blahTab.WinFormsObject("tabPage7").WinFormsObject("tabPriSec")]]}, 'Secondary RBE Scan Rate' : {'func' : setTextBox, 'formprop' : "Prop_blah7", 'tab': "RBE", 'navfunc' : [clickConfigSubTab], 'navfuncargs' : [["Secondary", Aliases.blatApp.blahTab1.WinFormsObject("tabPage7").WinFormsObject("tabPriSec")]]}, 'Secondary RBE Scan Slice' : {'func' : setTextBox, 'formprop' : "Prop_blah8", 'tab': "RBE", 'navfunc' : [clickConfigSubTab], 'navfuncargs' : [["Secondary", Aliases.blatApp.blahTab.WinFormsObject("tabPage7").WinFormsObject("tabPriSec")]]}, 'Secondary RBE Timeout' : {'func' : setTextBox, 'formprop' : "Prop_blah9", 'tab': "RBE", 'navfunc' : [clickConfigSubTab], 'navfuncargs' : [["Secondary", Aliases.blatApp.blahTab.WinFormsObject("tabPage7").WinFormsObject("tabPriSec")]]}, } clickConfigSubTab("RBE") for propname in propvalueDict.keys(): if propfuncBlahTabDict[propname]['tab'] == "RBE": if 'navfunc' in propfuncBlahTabDict[propname]: executeNavFuncs(propfuncBlahTabDict[propname]['navfunc'], propfuncBlahTabDict[propname]['navfuncargs']) propfuncBlahTabDict[propname]['func'](propfuncBlahTabDict[propname]['formprop'], propvalueDict[propname]) def executeNavFuncs(navfuncValue, navfunargsValue): navfunargsIndex = 0 for func in navfuncValue: func(*navfunargsValue[navfunargsIndex]) navfunargsIndex = navfunargsIndex + 1 And then use this to set them: def mapBlahDriver(): propvalueDict = collections.OrderedDict() propvalueDict["RBE Init Message"] = cbChecked propvalueDict["Primary RBE Scan Rate"] = 6 propvalueDict["Secondary RBE Scan Rate"] = 7 mapBlah("blahobject", propvalueDict) So...what does everyone else do? Guidance?1.1KViews0likes3CommentsRe: How to fetch element property values from list
I don't think you can examine elements of a Python list object in Debug view. I have never been able to do that, somewhat inconvenient. Fortunately Object Spy is very cool. Looks like a ListView object you've got there. To see what is in there I would suggest first going to "Advanced View" in object spy. Point at your listview object like you have already done in your screen shot. Go to "Items" under .NET in Advanced View Object Spy. Go click on the "...", type in an item index (like 0) and start drilling down into the item hierarchy. Once you can drill down into the listview to the items in Object Spy, copy the full path at the top and start playing with that in script. Eventually you should be able access the items from script like this... Aliases.TestAppBlah.blahForm.blah1.blah2.listView1.Items.Item[0] ^You'll probably want to find something less brittle than a numerical index but that should get you started. Hope that helps.2KViews1like6CommentsRe: specifying project in a TestExecute run
m_essaid wrote: Hi, If I read correctly there is no way to specify the project while running a test with TestExecute ? TestExecute can only run a whole Project Suite n which project and items are checked or not ? It's a little bit annoying for parrallel testing... Thanks, Mehdi Umm I'm quite sure it is possible to drill down into the project you want and event the keyword test or script that you want to run. You'll simply have to use the command line (with a lot of arguments). I did it once when I was evaluating TestExecute for the first time to see if it actually worked although that was a while ago so I don't have a sample for you. See the info here for how to use the CLI to do what you want: https://support.smartbear.com/viewarticle/90518/2.3KViews1like0CommentsRe: Need support regarding scripting and running tests using python in TestComplete
Rajesh2 Did TC log anything when you ran the script? That code sample also makes some assumptions: 1. You have Python 2.7 installed. Be aware: TC uses a subset of Python 3. I just have Python 2 installed on my system because I want to access scripts written against Python 2. 2. You have a windows PATH entry in your environmental variables pointed at the Python 2.7 folder. 3. You have the sample python script being called in the 'Scripts' directory. 4. Your network (consult IT) will not block the e-mail from being sent. ^If all of those conditions are met and it still does not work, let me know. To be clear, the code sample I posted was intended as a starting point, not something you just plug-in with no regard to how your system and network are set up and it works via magic.1.9KViews1like0Comments