Forum Discussion

hokrani's avatar
hokrani
Contributor
16 years ago

Change Name mapped object property value

Can we change the property value of the object which is already Name mapped . while adding object in name mapping i.e. in 'Name Mapping Item' pop up window, corresponding property is not selected i..e its in 'Available' list.  



For more detail:

I Created Name mapped for the object of the button 'Import'. I selected the following property

"NativeClrObject=btnImport' but not selected 'WPFControlIndex" property which is value 2.



Using the
aqObject
.SetPropertyValue , set the property value of the ''WPFControlIndex' to 3 but after executing the following code, still get the value 2 instead of 3



See the below code:


Set btnImport=Aliases.Waters_Portal.btnImport


aqObject.SetPropertyValue btnImport,WPFControlIndex,3


Msgbox btnImport.WPFControlIndex  ' Display 2 instead of 3.



Can anyone tell me where i'm doing wrong.

7 Replies

  • When i open the application, initially only one 'Import' button displayed i.e.'WPFControlIndex' is 1. While Name mapping for this object, i'm not selected 'WPFControlIndex" property .



    When i do some operation it will add one more 'Import' button i.e. 'WPFControlIndex' is now 2.



    Now i don't want Name mapp for the 2nd 'Import' button.



    Using the 1st name mapping object, just i want to change property value of the 'WPFControlIndext' value, click on it 2nd 'Import' button.



    Can any one answer for me.





  • Hi,



    Let me interpret the situation you have. If I understand you correctly, you have two buttons with the same 'Import' caption, but with different WPFControlIndex values, and for some reason, you don't want to create a separate mapped object for the second Import button. So, you are trying to use the same mapped object for both buttons by changing the mapping criteria.



    In this scenario, the best solution is to obtain the needed button from script using the FindChild method. Replace dummy values in angle brackets with actual values.





    var PropArray, ValuesArray, p, w;

    PropArray = new Array("NativeClrObject.Name", "WPFControlIndex");

    ValuesArray = new Array(<the property value>, 1);

    var btn = <parent form>.FindChild(PropArray, ValuesArray, 100);

    btn.Click();


  • Very simply question :



    In which scenario will use 'SetPropertyValue' method ? Give me with example.

  • Hello,





    The SetPropertyValue method is used when the name of the object property can be different in different cases, and you need to specify the property name programmatically.


  • Now by programmatically, i want to change the property value "WPFControlIndex" 1 to 2 for object 'btnImport'. By using 'SetPropertyValue" method, it wil not work.



    Is there any way ?



    -Hoks

  • Hello Hoks,





    First, I recommend that you update to version 8.10. It contains a bunch of improvement of the Name Mapping feature.





    As I mentioned, the WPFControlIndex property is read-only, it cannot be written. Actually, you do not need to change this property.





    By default, TestComplete uses the NativeClrObject.Name property to identify objects of .Net Open applications. In your case, it seems that non-default criteria are used. Did you configure Name Mapping Templates (right-click in the Name Mapping tree and select Templates...)? If there are some templates in the list, remove them and see whether the problem with duplicated objects persists. Please read more about Name Mapping Templates in the Creating, Editing and Deleting Name Mapping Templates help topic.





    If the advice above does not help, let's try to narrow down the problem. If you can determine the moment when the duplicated object for the Import button appears, try to reproduce the problem with a simple test. First, record a test with the Import button so that TestComplete maps the button. After that, find the parent window of the problematic button in the Object Browser and create a snapshot of this window. In the Save Object Snapshot Dialog, choose the  "All properties" option and check the "Save recursively" check box. 





    Then perform the actions with the tested application that usually lead to appearing of the duplicated object. After the duplicated object appears, make another object snapshot of the button's parent object.





    Finally, pack the entire project suite folder along with the snapshots and send it to Support.