Loading ...
Sorry, an error occurred while loading the content.

Re: Waiting for application response

Expand Messages
  • negedi
    I have used cpu load for synch in such cases - wait for CPU to be les that 2-3%. But it is not aplicable in all cases.
    Message 1 of 11 , Nov 16, 2004
    • 0 Attachment
      I have used cpu load for synch in such cases - wait for CPU to be les
      that 2-3%. But it is not aplicable in all cases.



      --- In perlguitest@yahoogroups.com, Darren Blee <d_blee@y...> wrote:
      >
      >
      > There is a windows function called IsWindowEnabled.
      > If it is not available via GUI Test, and I assume from
      > these threads that it is not, then you could use the
      > Win32::API module to call it.
      >
      > BOOL IsWindowEnabled(
      > HWND hWnd // handle of window to test
      > );
      >
      > It takes as an argument the window handle and returns
      > a boolean as to if windows believes the program can
      > recieve input or not. If the cursor is not an
      > hourglass then this function will not help (as windows
      > has not been told by the app that it is not ready to
      > recieve input).
      >
      > Note that a child window receives input only if it is
      > both enabled and visible. There is a IsWindowVisible
      > function as well but I doubt that you'll need it.
      >
      > Dennis however makes a good point. If the GUI has no
      > other visual indicators then you have to create some.
      >
      > - Darren
      >
      > --- "Dennis K. Paulsen" <ctrondlpaulsden@y...>
      > wrote:
      >
      > ---------------------------------
      >
      >
      > Hello,
      >
      > Here are a few thoughts...
      >
      > > What to do when some GUI operations take time (which
      >
      > > manifests in most cases by a hourglass and by not
      > reacting on any
      > > input).
      >
      > I suppose many of us don't have much control over such
      > poorly
      > written programs. :-( Usually, a well built GUI
      > application will
      > always & easily keep the user "in the loop" and not
      > just show an
      > hourglass and restrict input, for example a status-bar
      > or
      > appropriate messaging usually suffices...
      >
      > In cases such as yours, we generally need to look for
      > some change in
      > the GUI, i.e. text, disabling/enabling of a button, a
      > new window,
      > etc.... If its text, a for-loop and
      > WMGetText/GetWindowText usually
      > does the job, if its a button use IsWindowEnabled, and
      > if its a new
      > window, WaitWindowLike (note: default timeout of 10
      > can easily be
      > overridden) will get the job done...
      >
      > >The way many people workaround this right now, is
      > that they place a
      > >sleep in their script. Function WaitWindowLike works
      > this way. My
      > > question is - is there a Win32 mechanism/function
      > allowing to get
      > > information if application is waiting for input or
      > is it in the
      > > middle of something.
      >
      > There shouldn't be too many cases where a sleep
      > statement still
      > needs to be used... WaitWindowLike only uses a delay
      > (500ms select
      > statement) in order not to "bog down" the system....
      >
      >
      > And a GUI application is usually always waiting for
      > input and always
      > doing something (processing messages, etc.), so that
      > generally
      > doesn't help.... Historically, the highly pristine
      > method is to
      > wait for a GUI change; which is *the* solution to use
      > if your intent
      > is to -test- a particular application...
      >
      > Regards,
      > D
      >
      > --- In perlguitest@yahoogroups.com, "pkaluski"
      > <pkaluski@p...> wrote:
      > >
      > > OK. Maybe I was not clear enough. Application works
      > fine. My
      > question
      > > is more general. What to do when some GUI operations
      > take time
      > (which
      > > manifests in most cases by a hourglass and by not
      > reacting on any
      > > input). If your test script will not give tested
      > application some
      > > time to recover, it will fail on finding some new
      > windows or
      > controls
      > > which were expected to appear once the GUI operation
      > is complete.
      > The
      > > way many people workaround this right now, is that
      > they place a
      > sleep
      > > in their script. Function WaitWindowLike works this
      > way. My
      > question
      > > is - is there a Win32 mechanism/function allowing to
      > get
      > information
      > > if application is waiting for input or is it in the
      > middle of
      > > something.
      > > --Piotr
      > >
      > > --- In perlguitest@yahoogroups.com, ab dk
      > <cazaawi@y...> wrote:
      > > >
      > > > It sounds like you have to re-establishe the
      > focus.
      > > > It could be that your application is waiting for
      > an event that
      > does
      > > not happen. I hope this could be helpful.
      > > >
      > > > pkaluski <pkaluski@p...> wrote:
      > > >
      > > > Hi,
      > > > My automated test contains a part when I populate
      > one field and
      > > then
      > > > as a result another control is populated. It takes
      > time (10 - 15
      > > > seconds). Cursor disappears and the application
      > does not accept
      > any
      > > > input. Currently my workaround is that I am doing
      > a long sleep.
      > Is
      > > > there a more civilized way of finding out if
      > application is
      > ready
      > > to
      > > > receive more input?
      > > >
      > > > --Piotr
      > > > www.piotrkaluski.com
      > > > www.guiautomation.com
      > > >
      > > >
      > > >
      > > >
      > > >
      > > > Yahoo! Groups SponsorADVERTISEMENT
      > > >
      > > >
      > > > ---------------------------------
      > > > Yahoo! Groups Links
      > > >
      > > > To visit your group on the web, go to:
      > > > http://groups.yahoo.com/group/perlguitest/
      > > >
      > > > To unsubscribe from this group, send an email
      > to:
      > > > perlguitest-unsubscribe@yahoogroups.com
      > > >
      > > > Your use of Yahoo! Groups is subject to the
      > Yahoo! Terms of
      > > Service.
      > > >
      > > >
      > > >
      > > > [Non-text portions of this message have been
      > removed]
      >
      >
      >
      >
      > Yahoo! Groups Sponsor ADVERTISEMENT
      >
      >
      > ---------------------------------
      > Yahoo! Groups Links
      >
      > To visit your group on the web, go to:
      > http://groups.yahoo.com/group/perlguitest/
      >
      > To unsubscribe from this group, send an email to:
      > perlguitest-unsubscribe@yahoogroups.com
      >
      > Your use of Yahoo! Groups is subject to the Yahoo!
      > Terms of Service.
      >
      >
      > Find local movie times and trailers on Yahoo! Movies.
      > http://au.movies.yahoo.com
    • pkaluski
      Hi, Thanks for the response. I am afraid that IsWindowEnabled is not going to help me. To my knowledge based on some experiments, IsWindowEnabled returns
      Message 2 of 11 , Nov 16, 2004
      • 0 Attachment
        Hi,
        Thanks for the response. I am afraid that IsWindowEnabled is not
        going to help me. To my knowledge based on some experiments,
        IsWindowEnabled returns control's property, which decides if the
        control should or should not accept input. It does not give you
        information that control is not able to accept any input because the
        the application is busy doing something else.
        --Piotr

        --- In perlguitest@yahoogroups.com, Darren Blee <d_blee@y...> wrote:
        >
        >
        > There is a windows function called IsWindowEnabled.
        > If it is not available via GUI Test, and I assume from
        > these threads that it is not, then you could use the
        > Win32::API module to call it.
        >
        > BOOL IsWindowEnabled(
        > HWND hWnd // handle of window to test
        > );
        >
        > It takes as an argument the window handle and returns
        > a boolean as to if windows believes the program can
        > recieve input or not. If the cursor is not an
        > hourglass then this function will not help (as windows
        > has not been told by the app that it is not ready to
        > recieve input).
        >
        > Note that a child window receives input only if it is
        > both enabled and visible. There is a IsWindowVisible
        > function as well but I doubt that you'll need it.
        >
        > Dennis however makes a good point. If the GUI has no
        > other visual indicators then you have to create some.
        >
        > - Darren
        >
        > --- "Dennis K. Paulsen" <ctrondlpaulsden@y...>
        > wrote:
        >
        > ---------------------------------
        >
        >
        > Hello,
        >
        > Here are a few thoughts...
        >
        > > What to do when some GUI operations take time (which
        >
        > > manifests in most cases by a hourglass and by not
        > reacting on any
        > > input).
        >
        > I suppose many of us don't have much control over such
        > poorly
        > written programs. :-( Usually, a well built GUI
        > application will
        > always & easily keep the user "in the loop" and not
        > just show an
        > hourglass and restrict input, for example a status-bar
        > or
        > appropriate messaging usually suffices...
        >
        > In cases such as yours, we generally need to look for
        > some change in
        > the GUI, i.e. text, disabling/enabling of a button, a
        > new window,
        > etc.... If its text, a for-loop and
        > WMGetText/GetWindowText usually
        > does the job, if its a button use IsWindowEnabled, and
        > if its a new
        > window, WaitWindowLike (note: default timeout of 10
        > can easily be
        > overridden) will get the job done...
        >
        > >The way many people workaround this right now, is
        > that they place a
        > >sleep in their script. Function WaitWindowLike works
        > this way. My
        > > question is - is there a Win32 mechanism/function
        > allowing to get
        > > information if application is waiting for input or
        > is it in the
        > > middle of something.
        >
        > There shouldn't be too many cases where a sleep
        > statement still
        > needs to be used... WaitWindowLike only uses a delay
        > (500ms select
        > statement) in order not to "bog down" the system....
        >
        >
        > And a GUI application is usually always waiting for
        > input and always
        > doing something (processing messages, etc.), so that
        > generally
        > doesn't help.... Historically, the highly pristine
        > method is to
        > wait for a GUI change; which is *the* solution to use
        > if your intent
        > is to -test- a particular application...
        >
        > Regards,
        > D
        >
        > --- In perlguitest@yahoogroups.com, "pkaluski"
        > <pkaluski@p...> wrote:
        > >
        > > OK. Maybe I was not clear enough. Application works
        > fine. My
        > question
        > > is more general. What to do when some GUI operations
        > take time
        > (which
        > > manifests in most cases by a hourglass and by not
        > reacting on any
        > > input). If your test script will not give tested
        > application some
        > > time to recover, it will fail on finding some new
        > windows or
        > controls
        > > which were expected to appear once the GUI operation
        > is complete.
        > The
        > > way many people workaround this right now, is that
        > they place a
        > sleep
        > > in their script. Function WaitWindowLike works this
        > way. My
        > question
        > > is - is there a Win32 mechanism/function allowing to
        > get
        > information
        > > if application is waiting for input or is it in the
        > middle of
        > > something.
        > > --Piotr
        > >
        > > --- In perlguitest@yahoogroups.com, ab dk
        > <cazaawi@y...> wrote:
        > > >
        > > > It sounds like you have to re-establishe the
        > focus.
        > > > It could be that your application is waiting for
        > an event that
        > does
        > > not happen. I hope this could be helpful.
        > > >
        > > > pkaluski <pkaluski@p...> wrote:
        > > >
        > > > Hi,
        > > > My automated test contains a part when I populate
        > one field and
        > > then
        > > > as a result another control is populated. It takes
        > time (10 - 15
        > > > seconds). Cursor disappears and the application
        > does not accept
        > any
        > > > input. Currently my workaround is that I am doing
        > a long sleep.
        > Is
        > > > there a more civilized way of finding out if
        > application is
        > ready
        > > to
        > > > receive more input?
        > > >
        > > > --Piotr
        > > > www.piotrkaluski.com
        > > > www.guiautomation.com
        > > >
        > > >
        > > >
        > > >
        > > >
        > > > Yahoo! Groups SponsorADVERTISEMENT
        > > >
        > > >
        > > > ---------------------------------
        > > > Yahoo! Groups Links
        > > >
        > > > To visit your group on the web, go to:
        > > > http://groups.yahoo.com/group/perlguitest/
        > > >
        > > > To unsubscribe from this group, send an email
        > to:
        > > > perlguitest-unsubscribe@yahoogroups.com
        > > >
        > > > Your use of Yahoo! Groups is subject to the
        > Yahoo! Terms of
        > > Service.
        > > >
        > > >
        > > >
        > > > [Non-text portions of this message have been
        > removed]
        >
        >
        >
        >
        > Yahoo! Groups Sponsor ADVERTISEMENT
        >
        >
        > ---------------------------------
        > Yahoo! Groups Links
        >
        > To visit your group on the web, go to:
        > http://groups.yahoo.com/group/perlguitest/
        >
        > To unsubscribe from this group, send an email to:
        > perlguitest-unsubscribe@yahoogroups.com
        >
        > Your use of Yahoo! Groups is subject to the Yahoo!
        > Terms of Service.
        >
        >
        > Find local movie times and trailers on Yahoo! Movies.
        > http://au.movies.yahoo.com
      • pkaluski
        I think I found what I needed (it works for me): (I apologize if an indentation is bad) my $get_handle = Win32::API- new ( Kernel32 , OpenProcess , NIN ,
        Message 3 of 11 , Nov 16, 2004
        • 0 Attachment
          I think I found what I needed (it works for me):
          (I apologize if an indentation is bad)

          my $get_handle = Win32::API->new
          ( 'Kernel32', 'OpenProcess', 'NIN', 'N' );
          my $proc_handle = $get_handle->Call( 0x001F0FFF, 1, 2868 );
          my $get_idle = Win32::API->new
          ( 'User32', 'WaitForInputIdle', 'IN', 'N' );
          $get_idle->Call( $proc_handle, 20000 );


          Explanation of magic numbers:
          0x001F0FFF - access rights
          2868 - PID of tested application

          --Piotr


          --- In perlguitest@yahoogroups.com, "pkaluski" <pkaluski@p...> wrote:
          >
          > Hi,
          > Thanks for the response. I am afraid that IsWindowEnabled is not
          > going to help me. To my knowledge based on some experiments,
          > IsWindowEnabled returns control's property, which decides if the
          > control should or should not accept input. It does not give you
          > information that control is not able to accept any input because
          the
          > the application is busy doing something else.
          > --Piotr
          >
        • Mike T
          I have used eg Pause( Check if ok so far then press ENTER... ); # to test some condition visually that has timing issues a 10 second wait won t address # This
          Message 4 of 11 , Nov 16, 2004
          • 0 Attachment
            I have used eg

            Pause("Check if ok so far then press ENTER...");
            # to test some condition visually that has timing issues a 10 second wait won't address
            # This results in semi -attended testing where I can be busy manually on one workstation while guiTest runs on a second one
            # you can also pop the command window to the foreground to answer the prompt

            my ($termWindow) = FindWindowLike(0, "Command Prompt");

            SetForegroundWindow($termWindow);

            # then set context back to your app window


            Most of the guiTest tests I have written are data entry things that loop through a few forms 20 or 30 times to input varied data entry, because this is a brain- numbing thing to do manually. I do not use gui test to test complex workflows and complex business conditions.

            hth --Mike Tierney

            ----- Original Message -----
            From: pkaluski
            To: perlguitest@yahoogroups.com
            Sent: Tuesday, November 16, 2004 5:21 AM
            Subject: [perlguitest] Re: Waiting for application response



            Hi,
            Thanks for the response. I am afraid that IsWindowEnabled is not
            going to help me. To my knowledge based on some experiments,
            IsWindowEnabled returns control's property, which decides if the
            control should or should not accept input. It does not give you
            information that control is not able to accept any input because the
            the application is busy doing something else.
            --Piotr

            --- In perlguitest@yahoogroups.com, Darren Blee <d_blee@y...> wrote:
            >
            >
            > There is a windows function called IsWindowEnabled.
            > If it is not available via GUI Test, and I assume from
            > these threads that it is not, then you could use the
            > Win32::API module to call it.
            >
            > BOOL IsWindowEnabled(
            > HWND hWnd // handle of window to test
            > );
            >
            > It takes as an argument the window handle and returns
            > a boolean as to if windows believes the program can
            > recieve input or not. If the cursor is not an
            > hourglass then this function will not help (as windows
            > has not been told by the app that it is not ready to
            > recieve input).
            >
            > Note that a child window receives input only if it is
            > both enabled and visible. There is a IsWindowVisible
            > function as well but I doubt that you'll need it.
            >
            > Dennis however makes a good point. If the GUI has no
            > other visual indicators then you have to create some.
            >
            > - Darren
            >
            > --- "Dennis K. Paulsen" <ctrondlpaulsden@y...>
            > wrote:
            >
            > ---------------------------------
            >
            >
            > Hello,
            >
            > Here are a few thoughts...
            >
            > > What to do when some GUI operations take time (which
            >
            > > manifests in most cases by a hourglass and by not
            > reacting on any
            > > input).
            >
            <snip>

            [Non-text portions of this message have been removed]
          • Darren Blee
            Wow - what a fantastic solution. So basically your waiting for the on_idle event. Let us know how reliable it is.. Do you have time for a more detail
            Message 5 of 11 , Nov 16, 2004
            • 0 Attachment
              Wow - what a fantastic solution.

              So basically your waiting for the on_idle event.
              Let us know how reliable it is..

              Do you have time for a more detail explaination of the
              code or maybe a reference?

              Either way I'll be using this code myself - thanks!

              - Darren

              --- pkaluski <pkaluski@...> wrote:

              ---------------------------------

              I think I found what I needed (it works for me):
              (I apologize if an indentation is bad)

              my $get_handle = Win32::API->new
              ( 'Kernel32', 'OpenProcess', 'NIN', 'N' );
              my $proc_handle = $get_handle->Call( 0x001F0FFF, 1,
              2868 );
              my $get_idle = Win32::API->new
              ( 'User32', 'WaitForInputIdle', 'IN', 'N' );
              $get_idle->Call( $proc_handle, 20000 );


              Explanation of magic numbers:
              0x001F0FFF - access rights
              2868 - PID of tested application

              --Piotr


              --- In perlguitest@yahoogroups.com, "pkaluski"
              <pkaluski@p...> wrote:
              >
              > Hi,
              > Thanks for the response. I am afraid that
              IsWindowEnabled is not
              > going to help me. To my knowledge based on some
              experiments,
              > IsWindowEnabled returns control's property, which
              decides if the
              > control should or should not accept input. It does
              not give you
              > information that control is not able to accept any
              input because
              the
              > the application is busy doing something else.
              > --Piotr
              >





              Yahoo! Groups Sponsor ADVERTISEMENT


              ---------------------------------
              Yahoo! Groups Links

              To visit your group on the web, go to:
              http://groups.yahoo.com/group/perlguitest/

              To unsubscribe from this group, send an email to:
              perlguitest-unsubscribe@yahoogroups.com

              Your use of Yahoo! Groups is subject to the Yahoo!
              Terms of Service.


              Find local movie times and trailers on Yahoo! Movies.
              http://au.movies.yahoo.com
            • pkaluski
              Hi, For detailed explanation of the meaning of a function I have used you should go to msdn.microsoft.com. The details sufficient (hopefully) to understand my
              Message 6 of 11 , Nov 16, 2004
              • 0 Attachment
                Hi,
                For detailed explanation of the meaning of a function I have used you
                should go to msdn.microsoft.com. The details sufficient (hopefully)
                to understand my code goes below:

                my $get_handle = Win32::API->new
                ( 'Kernel32', 'OpenProcess', 'NIN', 'N' );
                my $proc_handle = $get_handle->Call( 0x001F0FFF, 1,
                2868 );
                my $get_idle = Win32::API->new
                ( 'User32', 'WaitForInputIdle', 'IN', 'N' );
                $get_idle->Call( $proc_handle, 20000 );

                Win32::API module is used. Its main purpose is to allow you to
                call any (almost any?) function from a given dll.
                Let's now go to the end. WaitForInputIdle (quoting MS docs) "waits
                until the specified process is waiting for user input with no input
                pending, or until the time-out interval has elapsed.".
                WaitForInputIdle needs a process handle. Process handle is not PID!
                In order to get the process handle you have to "attach" to it. You do
                it by calling OpenProcess. It takes 3 parameters - access rights,
                indicator if handles can be inherited (whatever this means) and PID.
                0x001F0FFF in my code means full access, 1 means true (I don't know
                if the second parameter of OpenProcess really matters in my
                expample). 2868 is process's PID.
                So let's rephrase it:
                OpenProcess gives the process handle. Using that handle you can check
                if the process is ready for input.

                In order to make it really usable geting PID of tested application
                has to be implemented. And I believe I know how to do it - function
                GetWindowThreadProcessId may help. I tried to call it with Win32::API
                but it did not work. So I think the best way is to code it in
                GuiTest.xs module. I will try to show you the final solution next
                week.

                Last question - how reliable it is?
                Well it works for my case - this is the only think I can tell for
                sure. I am not a Win32 programming guru, so I can't tell you that
                from the theoretical point of view it is always going to work. I
                think we have to give it a try and see how it behaves in different
                circumstances.

                -Piotr


                --- In perlguitest@yahoogroups.com, Darren Blee <d_blee@y...> wrote:
                >
                > Wow - what a fantastic solution.
                >
                > So basically your waiting for the on_idle event.
                > Let us know how reliable it is..
                >
                > Do you have time for a more detail explaination of the
                > code or maybe a reference?
                >
                > Either way I'll be using this code myself - thanks!
                >
                > - Darren
                >
                > --- pkaluski <pkaluski@p...> wrote:
                >
                > ---------------------------------
                >
                > I think I found what I needed (it works for me):
                > (I apologize if an indentation is bad)
                >
                > my $get_handle = Win32::API->new
                > ( 'Kernel32', 'OpenProcess', 'NIN', 'N' );
                > my $proc_handle = $get_handle->Call( 0x001F0FFF, 1,
                > 2868 );
                > my $get_idle = Win32::API->new
                > ( 'User32', 'WaitForInputIdle', 'IN', 'N' );
                > $get_idle->Call( $proc_handle, 20000 );
                >
                >
                > Explanation of magic numbers:
                > 0x001F0FFF - access rights
                > 2868 - PID of tested application
                >
                > --Piotr
                >
                >
                > --- In perlguitest@yahoogroups.com, "pkaluski"
                > <pkaluski@p...> wrote:
                > >
                > > Hi,
                > > Thanks for the response. I am afraid that
                > IsWindowEnabled is not
                > > going to help me. To my knowledge based on some
                > experiments,
                > > IsWindowEnabled returns control's property, which
                > decides if the
                > > control should or should not accept input. It does
                > not give you
                > > information that control is not able to accept any
                > input because
                > the
                > > the application is busy doing something else.
                > > --Piotr
                > >
                >
                >
                >
                >
                >
                > Yahoo! Groups Sponsor ADVERTISEMENT
                >
                >
                > ---------------------------------
                > Yahoo! Groups Links
                >
                > To visit your group on the web, go to:
                > http://groups.yahoo.com/group/perlguitest/
                >
                > To unsubscribe from this group, send an email to:
                > perlguitest-unsubscribe@yahoogroups.com
                >
                > Your use of Yahoo! Groups is subject to the Yahoo!
                > Terms of Service.
                >
                >
                > Find local movie times and trailers on Yahoo! Movies.
                > http://au.movies.yahoo.com
              Your message has been successfully submitted and would be delivered to recipients shortly.