Ranorex

Form variable losses context

 
Post new topic   Reply to topic    Ranorex Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Gryphyn



Joined: 07 Dec 2006
Posts: 15

PostPosted: Thu Dec 07, 2006 1:25 am    Post subject: Form variable losses context
Ranorex .Net2.0 / C#

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

Code: click into code to enlarge

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
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Fri Dec 08, 2006 1:33 am    Post subject:
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: click into code to enlarge
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
Back to top
View user's profile Send private message Visit poster's website
Gryphyn



Joined: 07 Dec 2006
Posts: 15

PostPosted: Fri Dec 08, 2006 2:00 am    Post subject:
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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> Bug Reports All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum