Contributions
- 4.2KViews0likes0Comments
Re: How do I determine if a property exists on an object in c#?
That seems to have worked. I didn't think to try that as in almost all other situations it seems like if an object's property (or method) returns true or false, I don't have toexplicitlycast to bool in if statements. I wonder why this situation is different.4.3KViews0likes0CommentsRe: How do I determine if a property exists on an object in c#?
Nope. That appears to be what I need but I can't seem to get it to work properly. When I try if (!Connect.aqObject["IsSupported"](checkbox, "ValueChecked")) an InvalidCastException occurs. FYI, this is in C# via an open application communicating with TestComplete.4.5KViews0likes0CommentsHow do I determine if a property exists on an object in c#?
I cannot seem to find a way to determine if a property exists or not. For example, some of the checkboxes in our Delphi application contain ValueChecked and ValueUnChecked properties, which determines the string value when the checkbox is checked or unchecked. I currently get these properties via valueChecked = (string)checkbox["ValueChecked"]; valueUnChecked = (string)checkbox["ValueUnChecked"]; The problem is that not all checkboxes use these properties, and the ones that don't do not have these properties defined at all. So when this method is called in my code (generic method to handle setting the state of a checkbox) I get an error because TestComplete stalls waiting for the "ValueChecked" property, and when it's not found and times out it returns an object that can't be casted. I need a way to instantly check if a property exists on an object so I can take an alternative action in those cases. Even if my current method would work (I just have to check if the returned object's Exist property is true or false) it does not work for my case because the property check still has to wait until the timeout period before it determines that the property doesn't exist. I tried to find a Wait* method I could use (similar to WaitAliasChild) but all I could find was WaitProperty. However, that waits until the property is set to a specific value, and since I cannot predict what value the ValueChecked will be set to (in fact this code is meant to find that out) this does not work for me. I also tried using the componentObj.PropertyExists(Name), but this seems to fail as well as the VCLObject doesn't have the PropertyExists method. How can I efficiently and quickly determine if an object has a specific property?26KViews0likes7CommentsRe: How can I convert my TC objects in VB.Net to a compatible var type
Unfortunately, while this works for VB.Net objects, it does not work when you pass in C# var objects. For example, take the following method: public static void SetTextFieldValue(object textfieldObject, string value, bool useTabToExit = true) { var textfield = new var(textfieldObject); // .... do stuff here } if you pass in a var as the textfieldObject parameter, it fails with the (useless) exception of "var(VarDelegate)"1.1KViews0likes0CommentsRe: How can I convert my TC objects in VB.Net to a compatible var type
Thanks, I went with the passing in object solution to make it easier for now. As much as I'd like to force all the other QA people to learn and use C# I think that will take time away from the strained resources we already have.1.1KViews0likes0CommentsHow can I convert my TC objects in VB.Net to a compatible var type
I have a C# connected application that controls TestComplete/TestExecute. I am looking at hooking into my vast library of helper methods with a VB.Net class (so that less experienced QA developers can use it to write testing code). Right now in C# I have the following helper method: public class CamaUtils { /// <summary> /// Sets the text of a CustomCama text field /// </summary> /// <param name="textfield">Text field's test complete object</param> /// <param name="value">Value to set the text field to</param> /// <param name="useTabToExit">If Tab is used to exit the text field. If false this function will NOT remove the cursor from the text field</param> public static void SetTextFieldValue(var textfield, string value, bool useTabToExit = true) { if (textfield == new var(null)) throw new ArgumentNullException("Attempted to set the value of a text field without passing in the text field object"); textfield["SetFocus"](); textfield["Keys"]("^[Home]!^[End]"); // Clear the current value textfield["Keys"](TestingUtils.EscapeTestCompleteInputString(value)); if (useTabToExit) textfield["Keys"]("[Tab]"); } } This works fine when I interact with it from C#, but when I try to use the following VB.Net code: Dim window = Aliases.WinRDE.WaitAliasChild("fmPermitInsert", 1000) CamaUtils.SetTextFieldValue(window.txtPermitNo, action.Attributes.Item(PERMIT_NUM_PARAM)) This code causes the following exception: Unable to cast COM object of type 'System.__ComObject' to class type 'AutomatedQA.script.var'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface. What is required for me to cast a test complete object into a TestComplete var type?13KViews0likes4CommentsRe: How can I increase the timeout period?
Even starting my testing with // Connect to the Test Complete engine and start the project Connect.RunTest(testName, projectName, Path.GetFullPath(projectSuiteFile)); Connect.Options["Run"]["Timeout"] = 20000; still causes TC to time out after 10 seconds, not 20.2.8KViews0likes0Comments