[wtr-general] Re: JavaScript events timing problems with Watir

2009-04-16 Thread Paul Rogers
there are some ajax request statuses available in IE7 ( and presumably 8 )
but when I tried a long time back to get hold of them, I could find no way
of accessing them

On Thu, Apr 16, 2009 at 10:23 AM, Chuck van der Linden wrote:

>
>
>
> On Apr 15, 2:54 am, Jarmo Pertman  wrote:
> >When you do .click, then Watir
> > waits for page load (it might take 20 minutes), so why wouldn't it be
> > reasonable to wait until events have been processed?
> >
>
> I believe (and those more familiar with the watir code, and
> interacting with the browser please correct me if I am wrong about
> this.) this is because the browser provides status for things along
> the lines of "i'm loading a new page" and "the page is done loading".
> if you have the status line of your browser enabled you can even see
> this visually.   So the watir code can tell if a click resulted in a
> http request, and when the response to the request (and all the
> dependent requests associated with it) has completed.
>
>
>  I do not believe that there is any similar status indication of "I'm
> busy running javascript" and "I'm done running javascript"  hence how
> would the watir code KNOW when the client side scripting (that was
> invoked when the event was fired) has finished?
>
> If I'm wrong, and there's a way to tell if firing an event has caused
> javascript or other client side code to start executing, and also tell
> when that code is done executing, then yes, I think your request is
> reasonable.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---



[wtr-general] Re: JavaScript events timing problems with Watir

2009-04-16 Thread Chuck van der Linden



On Apr 15, 2:54 am, Jarmo Pertman  wrote:
>When you do .click, then Watir
> waits for page load (it might take 20 minutes), so why wouldn't it be
> reasonable to wait until events have been processed?
>

I believe (and those more familiar with the watir code, and
interacting with the browser please correct me if I am wrong about
this.) this is because the browser provides status for things along
the lines of "i'm loading a new page" and "the page is done loading".
if you have the status line of your browser enabled you can even see
this visually.   So the watir code can tell if a click resulted in a
http request, and when the response to the request (and all the
dependent requests associated with it) has completed.


 I do not believe that there is any similar status indication of "I'm
busy running javascript" and "I'm done running javascript"  hence how
would the watir code KNOW when the client side scripting (that was
invoked when the event was fired) has finished?

If I'm wrong, and there's a way to tell if firing an event has caused
javascript or other client side code to start executing, and also tell
when that code is done executing, then yes, I think your request is
reasonable.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---



[wtr-general] Re: JavaScript events timing problems with Watir

2009-04-16 Thread Chuck van der Linden

if it works manually and not automated it sounds like a sort of race
condition caused by the speed at which the automation is executing.

You could try simulating that in irb by making a little do structure
(or a 1.times do loop) that you nest the comands in, so it will
execute them quickly instead of at whatever pace you can manually type
in the commands, see if that simulates the issue.   if it does you can
experiment with some waits between the events to see if you can get it
to work reliably.

On Apr 16, 2:42 am, Jarmo Pertman  wrote:
> As I said, then everything works correctly when I use debugger and
> execute commands one by one (or even irb), so the problem is not
> related with invoking wrong event. Also, I have checked that onclick
> event is attached to it.
>
> On Apr 15, 11:18 pm, Chuck van der Linden  wrote:
>
>
>
> > Are you sure what event the javascript is looking for?  have you
> > looked at the object on the page and seen what event handlers are
> > defined for it?   maybe it's not the 'click' event that it wants?
> > maybe it wants some other sequence such as onfocus or onmouseup- Hide 
> > quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---



[wtr-general] Re: JavaScript events timing problems with Watir

2009-04-16 Thread Jarmo Pertman

As I said, then everything works correctly when I use debugger and
execute commands one by one (or even irb), so the problem is not
related with invoking wrong event. Also, I have checked that onclick
event is attached to it.

On Apr 15, 11:18 pm, Chuck van der Linden  wrote:
> Are you sure what event the javascript is looking for?  have you
> looked at the object on the page and seen what event handlers are
> defined for it?   maybe it's not the 'click' event that it wants?
> maybe it wants some other sequence such as onfocus or onmouseup
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---



[wtr-general] Re: JavaScript events timing problems with Watir

2009-04-15 Thread Chuck van der Linden

Are you sure what event the javascript is looking for?  have you
looked at the object on the page and seen what event handlers are
defined for it?   maybe it's not the 'click' event that it wants?
maybe it wants some other sequence such as onfocus or onmouseup

On Apr 15, 2:54 am, Jarmo Pertman  wrote:
> Well, for me the case is as following. User fills in some form and
> presses submit, which has onclick event attached to it, which in turn
> invokes JavaScript (not Java!) function, which validates form and if
> there are missing or invalid fields, submit will not be done and error
> message div will be created or updated with details what is wrong with
> fields. This seems to take more than my measured critical point, e.g.
> 220 ms. So it is not like 20 minutes. When you do .click, then Watir
> waits for page load (it might take 20 minutes), so why wouldn't it be
> reasonable to wait until events have been processed?
>
> Anyway, as I said, I can wait for error message div to be changed as
> my example code, which checks contents div html against old html, but
> it doesn't work. My questions were, why isn't onclick event fired (I
> can sleep even 10 seconds and it won't change error message div
> contents). If I click it manually, it takes below 1 second, always.
> So, sleep doesn't work either. It seems that for some reason win32ole
> IE object doesn't handle .click correctly in some strange situations.
> It doesn't even matter if I .fire_event("onclick") right after .click
> (or before). Also, as I've mentioned, then it will always work if I
> will execute commands one by one (with debugger or just while true;
> eval(gets); end;), so it seems that the problem is happening when I'm
> trying to do anything right after issuing .click. Even sleep hangs the
> process.
>
> How would you suggest that I'd use brute-force? Just click button so
> many times as error_message div changes finally?
>
> Jarmo
>
> On Apr 14, 9:55 pm, Chuck van der Linden  wrote:
>
>
>
> > On Apr 14, 5:42 am, Jarmo Pertman  wrote:
>
> > >Anyway, now I have completely different problem. Problem is related
> > >with fire_event. I have always assumed that Watir knows when
> > >fire_event call has finished, but it seems that IE will respond
> > >immediately to this call.
>
> > The firing of the event *has* finished amost as soon as it's started.
> > The issue is what processes are kicked off in the client side code
> > when the event is detected.
>
> >  I don't think Watir has (nor is it reasonable to expect it to have)
> > any way to tell what will happen when the event is fired, and how long
> > that will take to finish.  heck it could be a local flash animation or
> > something that takes 20 minutes to run.
>
> > brute force would just be to put in a wait (that would be long enough
> > to cover the time needed in any conceivable case), for the java to
> > finish doing it's thing.  Frankly unless execution speed is absolutely
> > critical, that would be my approach.
>
> > beyond that you'll have to examin what happens that is triggered by
> > the event, try to find the last thing it does, and make a loop or
> > something that looks for that to be the case (something is visible
> > perhaps?, or now exists that didn't exist before?   But you have to
> > ask yourself 'how long is it going to take me to do that, vs the time
> > I'd save during script execution over just using the brute force
> > method.  There may not be much return on the time invested to create
> > the more elegant solution.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---



[wtr-general] Re: JavaScript events timing problems with Watir

2009-04-15 Thread Jarmo Pertman

Well, for me the case is as following. User fills in some form and
presses submit, which has onclick event attached to it, which in turn
invokes JavaScript (not Java!) function, which validates form and if
there are missing or invalid fields, submit will not be done and error
message div will be created or updated with details what is wrong with
fields. This seems to take more than my measured critical point, e.g.
220 ms. So it is not like 20 minutes. When you do .click, then Watir
waits for page load (it might take 20 minutes), so why wouldn't it be
reasonable to wait until events have been processed?

Anyway, as I said, I can wait for error message div to be changed as
my example code, which checks contents div html against old html, but
it doesn't work. My questions were, why isn't onclick event fired (I
can sleep even 10 seconds and it won't change error message div
contents). If I click it manually, it takes below 1 second, always.
So, sleep doesn't work either. It seems that for some reason win32ole
IE object doesn't handle .click correctly in some strange situations.
It doesn't even matter if I .fire_event("onclick") right after .click
(or before). Also, as I've mentioned, then it will always work if I
will execute commands one by one (with debugger or just while true;
eval(gets); end;), so it seems that the problem is happening when I'm
trying to do anything right after issuing .click. Even sleep hangs the
process.

How would you suggest that I'd use brute-force? Just click button so
many times as error_message div changes finally?

Jarmo

On Apr 14, 9:55 pm, Chuck van der Linden  wrote:
> On Apr 14, 5:42 am, Jarmo Pertman  wrote:
>
> >Anyway, now I have completely different problem. Problem is related
> >with fire_event. I have always assumed that Watir knows when
> >fire_event call has finished, but it seems that IE will respond
> >immediately to this call.
>
> The firing of the event *has* finished amost as soon as it's started.
> The issue is what processes are kicked off in the client side code
> when the event is detected.
>
>  I don't think Watir has (nor is it reasonable to expect it to have)
> any way to tell what will happen when the event is fired, and how long
> that will take to finish.  heck it could be a local flash animation or
> something that takes 20 minutes to run.
>
> brute force would just be to put in a wait (that would be long enough
> to cover the time needed in any conceivable case), for the java to
> finish doing it's thing.  Frankly unless execution speed is absolutely
> critical, that would be my approach.
>
> beyond that you'll have to examin what happens that is triggered by
> the event, try to find the last thing it does, and make a loop or
> something that looks for that to be the case (something is visible
> perhaps?, or now exists that didn't exist before?   But you have to
> ask yourself 'how long is it going to take me to do that, vs the time
> I'd save during script execution over just using the brute force
> method.  There may not be much return on the time invested to create
> the more elegant solution.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---



[wtr-general] Re: JavaScript events timing problems with Watir

2009-04-14 Thread Chuck van der Linden

On Apr 14, 5:42 am, Jarmo Pertman  wrote:

>Anyway, now I have completely different problem. Problem is related
>with fire_event. I have always assumed that Watir knows when
>fire_event call has finished, but it seems that IE will respond
>immediately to this call.

The firing of the event *has* finished amost as soon as it's started.
The issue is what processes are kicked off in the client side code
when the event is detected.

 I don't think Watir has (nor is it reasonable to expect it to have)
any way to tell what will happen when the event is fired, and how long
that will take to finish.  heck it could be a local flash animation or
something that takes 20 minutes to run.

brute force would just be to put in a wait (that would be long enough
to cover the time needed in any conceivable case), for the java to
finish doing it's thing.  Frankly unless execution speed is absolutely
critical, that would be my approach.

beyond that you'll have to examin what happens that is triggered by
the event, try to find the last thing it does, and make a loop or
something that looks for that to be the case (something is visible
perhaps?, or now exists that didn't exist before?   But you have to
ask yourself 'how long is it going to take me to do that, vs the time
I'd save during script execution over just using the brute force
method.  There may not be much return on the time invested to create
the more elegant solution.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---



[wtr-general] Re: JavaScript events timing problems with Watir

2009-04-14 Thread Jarmo Pertman

Forgot to change topic of course :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~--~~~~--~~--~--~---