Contributions
why Test Complete not recognising DOT net objects?
Hello, I did scripting for one of my Dot net application few days back and it was running fine but today when I tried to run the same script i faced a problem ,initially let say in my application object spy traced mapped name of an object which is the actual name for it as"Aliases["KM_ISMS_FirePatrol_Desktop1"]" but today it got changed to "Aliases["KM_ISMS_FirePatrol_Desktop1"]["wndWindowsForms10Window8app0378734a"]" and the scripts stopped for new name mapping indeed there are already mapped name done by me. provided there is no change in application code.As you can see here an extended default object name is appearing. basically i can say its not recognizing dot net objects as i did checked it by adding dot net DLL using CLR bridge. Regards Priyanka19KViews0likes5CommentsRe: How to read XML in C# scripting using DOTnet classes??
Hello Allen, Thanks for response n suggestion :-) as suggested by you here Hi Priyanka, >>> it neither give any output even though it satisfies the condition ,control does not goes inside the if loop and log the message <<< I guess you just have a node which does not meet any of the specified conditions in your document. You can add a Log.Message call in the loop (e.g. Log.Message(nType)) to check all the node types. If this suggestion does not help, I recommend that you set a breakpoint and debug your script (see the "Debugging Tests - Overview" help topic ( http://www.automatedqa.com/ support/viewarticle.aspx?aid= 11335 ) for more information). >>> actually the problem is more intresting here as I already tried the method above suggested by you and yeah I did debugging as well but my problem is in this chunk of code function Class1() { var ws=0 var pi=0; var dc=0; var cc=0; var ac=0; var et=0; var el=0; var xd=0; //Read a doc textReader=dotNET["System_Xml" ]["XmlTextReader"]["zctor_11"] ("C:\\Documents and Settings\\priyankS\\Desktop\\ KBT.xml"); //Read until end of file while(textReader["Read"]()) { var nType=textReader["NodeType"]; //if node type use a declaration if(nType==dotNET["System_Xml"] ["XmlNodeType"][" XmlDeclaration"]) { Log["Message"]("Declaration:"+ textReader["Name"]) Log["Message"]("Hi") xd=xd+1; } the value in" if(nType==dotNET["System_Xml"] ["XmlNodeType"][" XmlDeclaration"])" both the side is same i.e" XmlDeclaration" type of object still the "==" equal to sign comparison gives false on debugging henceforth the control dont goes inside this loop. I don't know how come when both the side same value come on debugging then still it goes false. i request you to just run the code once at yours end and see the debugger reponse. "XmlDeclaration" must satisfy the loop! and for other code reply which is:- <<<< the above code gives sysntax error on execution <<< I believe the error is caused by the following line: var xeElementCollection = xeRootNode["Elements"]() GetEnumerator(); You missed the "." character between "xeRootNode["Elements"]()" and "GetEnumerator();" <<<<<<<< I am doing here C# scripting and i dont think "." dot character will solve the problem actually I did this coding in C# visual studio and ws trying to convert it into C# script .... so i asked for help in doing this anyways thnx again for help :-) Regards Priyanka1.1KViews0likes0CommentsHow to read XML in C# scripting using DOTnet classes??
hello, I want to read an XML using Dotnet classes for which i have already added the System_XML and System_XML_Linq assemblies in CLR bridge.but I am facing some problems while running the code and I am unable to relate the problem here i am sending you the piece of code which i wrote and the XML for same kindly look into it. and help me in effiently reading it. function Class1() { var ws=0 var pi=0; var dc=0; var cc=0; var ac=0; var et=0; var el=0; var xd=0; //Read a doc textReader=dotNET["System_Xml"]["XmlTextReader"]["zctor_11"]("C:\\Documents and Settings\\priyankS\\Desktop\\KBT.xml"); //Read until end of file while(textReader["Read"]()) { var nType=textReader["NodeType"]; //if node type use a declaration if(nType==dotNET["System_Xml"]["XmlNodeType"]["XmlDeclaration"]) { Log["Message"]("Declaration:"+textReader["Name"]) Log["Message"]("Hi") xd=xd+1; } //if node type is comment if(nType==dotNET["System_Xml"]["XmlNodeType"]["Comment"]) { Log["Message"]("Comment:"+textReader["Name"]); cc=cc+1; } //if node type is an attribute if(nType==dotNET["System_Xml"]["XmlNodeType"]["Attribute"]) { Log["Message"]("Attribute:"+textReader["Name"]); ac=ac+1; } } } //The XML which I am using here is //**************************************************************************** <?xml version="1.0" encoding="utf-8"?> <controls> <control Class="Button" Name0="Copy" Name1="Add" Name2="Save" Name3="Cancel" Name4="Delete" Name5="AutoReg" Name6="check"></control> <control Class="ListBox" ></control> <control Class="RadioButton" Name1="Show All" Name2="Selected" Name3="Not Used"></control> <control Class="Label" Name1="Name"></control> <control Class="TextBox"></control> <control Class="VScrollBar"></control> <control Class="DataGridViewTextBoxColumn" Name0="CheckPoint Tag" Name1="CheckPoint Name" Name2="Expected" Name3="MaxBefore" Name4="MaxAfter" ></control> <control Class="DataGridViewCheckBoxColumn" Name1="Include"></control> </controls> //****************************************************************************************************the above code does not throws any error on execution but it neither give any output even though it satisfies the condition ,control does not goes inside the if loop and log the message and the another piece of code on which I am trying is function Class2() { var xdXmlFile = dotNET["System_Xml_Linq"]["XDocument"]["Load_2"]("C:\\Documents and Settings\\priyankS\\Desktop\\KBT.xml"); var xeRootNode = xdXmlFile["Root"]; var xeElementCollection = xeRootNode["Elements"]()GetEnumerator(); //xeElementCollection.Reset(); while (xeElementCollection.MoveNext()) { var xeElement = xeElementCollection.Current; var xeAttributCollection = xeElement.Attributes().GetEnumerator(); while (xeAttributCollection.MoveNext()) { var xaAttribute = xeAttributCollection.Current; var AttributeName = xaAttribute.Name.LocalName; var AttributeValue = xaAttribute.Value; } } } the above code gives sysntax error on execution22KViews0likes4CommentsHow to read XML in C# scripting usingDOTnet classes
hello, I want to read an XML using Dotnet classes for which i have already added the System_XML and System_XML_Linq assemblies in CLR bridge.but I am facing some problems while running the code and I am unable to relate the problem here i am sending you the piece of code which i wrote and the XML for same kindly look into it. and help me in effiently reading it. function Class1() { var ws=0 var pi=0; var dc=0; var cc=0; var ac=0; var et=0; var el=0; var xd=0; //Read a doc textReader=dotNET["System_Xml"]["XmlTextReader"]["zctor_11"]("C:\\Documents and Settings\\priyankS\\Desktop\\KBT.xml"); //Read until end of file while(textReader["Read"]()) { var nType=textReader["NodeType"]; //if node type use a declaration if(nType==dotNET["System_Xml"]["XmlNodeType"]["XmlDeclaration"]) { Log["Message"]("Declaration:"+textReader["Name"]) Log["Message"]("Hi") xd=xd+1; } //if node type is comment if(nType==dotNET["System_Xml"]["XmlNodeType"]["Comment"]) { Log["Message"]("Comment:"+textReader["Name"]); cc=cc+1; } //if node type is an attribute if(nType==dotNET["System_Xml"]["XmlNodeType"]["Attribute"]) { Log["Message"]("Attribute:"+textReader["Name"]); ac=ac+1; } } } //The XML which I am using here is //**************************************************************************** <?xml version="1.0" encoding="utf-8"?> <controls> <control Class="Button" Name0="Copy" Name1="Add" Name2="Save" Name3="Cancel" Name4="Delete" Name5="AutoReg" Name6="check"></control> <control Class="ListBox" ></control> <control Class="RadioButton" Name1="Show All" Name2="Selected" Name3="Not Used"></control> <control Class="Label" Name1="Name"></control> <control Class="TextBox"></control> <control Class="VScrollBar"></control> <control Class="DataGridViewTextBoxColumn" Name0="CheckPoint Tag" Name1="CheckPoint Name" Name2="Expected" Name3="MaxBefore" Name4="MaxAfter" ></control> <control Class="DataGridViewCheckBoxColumn" Name1="Include"></control> </controls> //****************************************************************************************************the above code does not throws any error on execution but it neither give any output even though it satisfies the condition ,control does not goes inside the if loop and log the message and the another piece of code on which I am trying is function Class2() { var xdXmlFile = dotNET["System_Xml_Linq"]["XDocument"]["Load_2"]("C:\\Documents and Settings\\priyankS\\Desktop\\KBT.xml"); var xeRootNode = xdXmlFile["Root"]; var xeElementCollection = xeRootNode["Elements"]()GetEnumerator(); //xeElementCollection.Reset(); while (xeElementCollection.MoveNext()) { var xeElement = xeElementCollection.Current; var xeAttributCollection = xeElement.Attributes().GetEnumerator(); while (xeAttributCollection.MoveNext()) { var xaAttribute = xeAttributCollection.Current; var AttributeName = xaAttribute.Name.LocalName; var AttributeValue = xaAttribute.Value; } } } the above code gives sysntax error on execution17KViews0likes1Comment