Question

I have a number of methods like this.UIMap.FirstName,this.UIMap.LastName,this.UIMap.Email, etc.. etc.. in my coded UI designer. Each of the fields in the page have one method in designer. I am preparing a framework like, the field name is taken from excel, the corresponding method should be executed and the result should be written across the field name in the final STATUS column of the excel.

Am i making myself clear ? :) If so , how do i make a call to such a method. I have written something like this :

    string fieldname = WorkSheet.Cells[i, 2].Value;                         
    UIMap uimap = new UIMap();
    Type thisType = typeof(UIMap);
    thisType.InvokeMember(fieldname , BindingFlags.InvokeMethod | BindingFlags.Public,
 null, uimap,null);

But it is throwing error as :

Test method SampleDemo.CodedUITest1.CodedUITestMethod1 threw exception: System.MissingMethodException: Method 'SampleDemo.UIMap.FirstName1' not found.

Was it helpful?

Solution

your FirstName is a function or it just a property?if it's a property so you can get value from it not call a method by reflection

typeof(UIMap).GetProperty("FirstName").GetValue(this.UIMap)

code like this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top