Form variable losses context

Bug reports.
Gryphyn
Posts: 15
Joined: Wed Dec 06, 2006 11:59 pm

Form variable losses context

Post by Gryphyn » Thu Dec 07, 2006 12:25 am

Ranorex .Net2.0 / C#

I'm using a basic C# class to manage automation of dialogs.
Here's the simplified version.

Code: Select all

using System;
using Ranorex;

namespace SmokeTest.Expose
{
  public class BaseClass // named as required
  {
    private const String FormClass = "<class>";  // As appropriate
    private readonly Form Form;
    public BaseClass()
    {
      Form = Application.FindFormClassName(FormClass,1,true,2000); // I assume the form has already been created
      if (Form != null) Form.GetControls();
    }
    public Boolean Exists
    { get { return (Form != null); } }
    private Boolean Button(String Text)
    {
      if (!Exists) return false;
      Control Control = Form.FindChildText(Text);
      Boolean Success = (Control != null &&
                         Control.Enabled &&
                         Mouse.ClickControl(Control).Equals(0));
      if (Success) Form.GetControls(); //Refresh Controls
      return Success;
    }
    public Boolean Back
    { get { return (Exists && Button("< &Back")); } }
    public Boolean Next
    { get { return (Exists && Button("&Next >")); } }
    public Boolean Cancel
    { get { return (Exists && Button("Cancel")); } }
} }
This was working as desired under 0.9.4

I updated to (the free) 1.0.0, and this is now broken.
(and yes, I've reassigned my references to the new location of the Ranorex DLL's)

Tracing through the code, something in the Mouse.ClickControl() function is invalidating my Form variable (even though it's readonly)
Prior to the call it (the variable) reflects as a 'form', after it reflects as a 'Button'. I'm assuming it's something to do with the fact that the Mouse has clicked on a 'button' control

Cheers
Gryphyn

webops
Site Admin
Site Admin
Posts: 349
Joined: Wed Jul 05, 2006 7:44 pm

Post by webops » Fri Dec 08, 2006 12:33 am

I cannot reproduce this issue, i have written a simple C# console application and use your class in it.
I tried with the windows calculator, here is my source code:

Code: Select all

using System;
using Ranorex;

namespace RanorexVS2005Sample1
{
    public class BaseClass // named as required 
    {
        private const String FormClass = "SciCalc";  // As appropriate 
        private readonly Form Form;
        public BaseClass()
        {
            Form = Application.FindFormClassName(FormClass, 1, true, 2000);
            if (Form != null) Form.GetControls();
        }
        public Boolean Exists
        { get { return (Form != null); } }
        private Boolean Button(String Text)
        {
            if (!Exists) return false;
            Control Control = Form.FindChildText(Text);
            Boolean Success = (Control != null &&
                               Control.Enabled &&
                               Mouse.ClickControl(Control).Equals(0));
            if (Success) Form.GetControls(); //Refresh Controls 
            return Success;
        }
        public Boolean Back
        { get { return (Exists && Button("1")); } }
        public Boolean Next
        { get { return (Exists && Button("2")); } }
        public Boolean Cancel
        { get { return (Exists && Button("3")); } }
    }

    class Class1
    {
        [STAThread]
        static void Main(string[] args)
        {
            BaseClass myClass = new BaseClass();
            Boolean back = myClass.Back;
            Boolean next = myClass.Next;
            Boolean calcel = myClass.Cancel;
        }
    }
}
Jenö Herget
Ranorex Team

Gryphyn
Posts: 15
Joined: Wed Dec 06, 2006 11:59 pm

Post by Gryphyn » Fri Dec 08, 2006 1:00 am

Jenö

Thanks for the reply.

I've done some futher investigation.
It seems to be restricted to MSI installation dialogs.
I'm not sure if it is MSI itself, or 'Wise Installer' (which we wrap around a MSI install)

FormClass = "MsiDialogCloseClass";
*apparently there are different instances of this class that bare no resembance to each other - it is the class of the main dialog as well as for several popup dialogs. (this bit I was managing OK)

I have a work-around (rediscover the form) so it's not pressing.

Cheers
Gryphyn