[wtr-general] Re: Clicking a JavaScript image button
I've tried this previously to posting the thread, this gives the same result as the thing I posted, resulting in no error nor action. On Jan 15, 5:00 pm, wesley chen cjq@gmail.com wrote: require 'watir' ie=Watir::IE.start(your address) ie.image(:id,/btnLogin_imgButton/).click Thanks. Wesley Chen. On Thu, Jan 15, 2009 at 8:04 PM, Oded adlersb...@gmail.com wrote: Hello all, I'm fairly new to Watir, I'm trying to click on a certain image button with no success. My code looks like this: require watir ie = Watir::new ie.goto(host) ie.image(:id, 'btnLogin_imgButton').fire_event(OnMouseDown) ie.image(:id, 'btnLogin_imgButton').fire_event(OnMouseUp) ie.image(:id, 'btnLogin_imgButton').fire_event(OnMouseLeave) --- The above script gives no error, judging by the Ruby output it runs and performs its task but the button remains untouched. I've also tried using a simple .click cmd with no success. I can see from the source code that there's an event with a checkbox etc, but I could not figure out a way to work around it. The relevant source code for the page: img id=btnLogin_imgButton style=cursor:hand; onmouseup=btnLogin_OnMouseUp(); onmousedown=btnLogin_OnMouseDown (); onmouseover=btnLogin_OnMouseOver(); onmouseleave=btnLogin_OnMouseLeave(); / span style=display:none;input id=btnLogin_IsEnable type=checkbox name=btnLogin$IsEnable checked=checked //span script type=text/javascript var IsEnable = document.getElementById( 'btnLogin_IsEnable' ); function btnLogin_OnMouseOver() { if(document.getElementById( 'btnLogin_IsEnable').checked) event.srcElement.src='Images/New/buttons/login/ btn_login_over.png'; else event.srcElement.src='Images/New/buttons/login/ btn_login_disabled.png'; } function btnLogin_OnMouseLeave() { if(document.getElementById( 'btnLogin_IsEnable').checked) event.srcElement.src='Images/New/buttons/login/btn_login.png'; else event.srcElement.src='Images/New/buttons/login/ btn_login_disabled.png'; } function btnLogin_OnMouseDown() { if (event.button == 1) { if(document.getElementById( 'btnLogin_IsEnable').checked) event.srcElement.src='Images/New/buttons/login/ btn_login_click.png'; else event.srcElement.src='Images/New/buttons/login/ btn_login_disabled.png'; } } function btnLogin_OnMouseUp() { if (event.button == 1) { if(document.getElementById( 'btnLogin_IsEnable').checked) { event.srcElement.src='Images/New/buttons/login/btn_login.png'; Login(); } else event.srcElement.src='Images/New/buttons/login/ btn_login_disabled.png'; } } function btnLogin_None () {} var btnLogin = new function() { var img = document.getElementById ('btnLogin_imgButton'); this.ActiveImage = 'Images/New/buttons/login/ btn_login.png'; this.SelectedImage = 'Images/New/buttons/login/btn_login_click.png'; this.OverImage = 'Images/New/buttons/login/btn_login_over.png'; this.DisabledImage = 'Images/New/buttons/login/ btn_login_disabled.png'; this.Hide = function() { img.style.display='none'; }; this.Show = function() { img.style.display='inline'; }; this.Disable = function() { img.src=this.DisabledImage; document.getElementById('btnLogin_IsEnable').checked=false;}; this.Enable = function() { img.src=this.ActiveImage; document.getElementById('btnLogin_IsEnable').checked=true;}; }; document.getElementById('btnLogin_imgButton').src = document.getElementById('btnLogin_IsEnable').checked? 'Images/New/ buttons/login/btn_login.png':'Images/New/buttons/login/ btn_login_disabled.png'; /script Any kind of help would be appreciated, thanks. --~--~-~--~~~---~--~~ 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: Clicking a JavaScript image button
I don't know what will happen when the image button is triggered. Maybe it will succeed to separate the Javascript. such as: require 'watir' ie=Watir::IE.start(your address) ie.image(:id,/btnLogin_imgButton/).fire_event(onmouseup) # or ***.fire_event(onmousedown) or... ie.image(:id,/btnLogin_imgButton/).click Thanks. Wesley Chen. On Fri, Jan 16, 2009 at 3:29 AM, Oded adlersb...@gmail.com wrote: I've tried this previously to posting the thread, this gives the same result as the thing I posted, resulting in no error nor action. On Jan 15, 5:00 pm, wesley chen cjq@gmail.com wrote: require 'watir' ie=Watir::IE.start(your address) ie.image(:id,/btnLogin_imgButton/).click Thanks. Wesley Chen. On Thu, Jan 15, 2009 at 8:04 PM, Oded adlersb...@gmail.com wrote: Hello all, I'm fairly new to Watir, I'm trying to click on a certain image button with no success. My code looks like this: require watir ie = Watir::new ie.goto(host) ie.image(:id, 'btnLogin_imgButton').fire_event(OnMouseDown) ie.image(:id, 'btnLogin_imgButton').fire_event(OnMouseUp) ie.image(:id, 'btnLogin_imgButton').fire_event(OnMouseLeave) --- The above script gives no error, judging by the Ruby output it runs and performs its task but the button remains untouched. I've also tried using a simple .click cmd with no success. I can see from the source code that there's an event with a checkbox etc, but I could not figure out a way to work around it. The relevant source code for the page: img id=btnLogin_imgButton style=cursor:hand; onmouseup=btnLogin_OnMouseUp(); onmousedown=btnLogin_OnMouseDown (); onmouseover=btnLogin_OnMouseOver(); onmouseleave=btnLogin_OnMouseLeave(); / span style=display:none;input id=btnLogin_IsEnable type=checkbox name=btnLogin$IsEnable checked=checked //span script type=text/javascript var IsEnable = document.getElementById( 'btnLogin_IsEnable' ); function btnLogin_OnMouseOver() { if(document.getElementById( 'btnLogin_IsEnable').checked) event.srcElement.src='Images/New/buttons/login/ btn_login_over.png'; else event.srcElement.src='Images/New/buttons/login/ btn_login_disabled.png'; } function btnLogin_OnMouseLeave() { if(document.getElementById( 'btnLogin_IsEnable').checked) event.srcElement.src='Images/New/buttons/login/btn_login.png'; else event.srcElement.src='Images/New/buttons/login/ btn_login_disabled.png'; } function btnLogin_OnMouseDown() { if (event.button == 1) { if(document.getElementById( 'btnLogin_IsEnable').checked) event.srcElement.src='Images/New/buttons/login/ btn_login_click.png'; else event.srcElement.src='Images/New/buttons/login/ btn_login_disabled.png'; } } function btnLogin_OnMouseUp() { if (event.button == 1) { if(document.getElementById( 'btnLogin_IsEnable').checked) { event.srcElement.src='Images/New/buttons/login/btn_login.png'; Login(); } else event.srcElement.src='Images/New/buttons/login/ btn_login_disabled.png'; } } function btnLogin_None () {} var btnLogin = new function() { var img = document.getElementById ('btnLogin_imgButton'); this.ActiveImage = 'Images/New/buttons/login/ btn_login.png'; this.SelectedImage = 'Images/New/buttons/login/btn_login_click.png'; this.OverImage = 'Images/New/buttons/login/btn_login_over.png'; this.DisabledImage = 'Images/New/buttons/login/ btn_login_disabled.png'; this.Hide = function() { img.style.display='none'; }; this.Show = function() { img.style.display='inline'; }; this.Disable = function() { img.src=this.DisabledImage; document.getElementById('btnLogin_IsEnable').checked=false;}; this.Enable = function() { img.src=this.ActiveImage; document.getElementById('btnLogin_IsEnable').checked=true;}; }; document.getElementById('btnLogin_imgButton').src = document.getElementById('btnLogin_IsEnable').checked? 'Images/New/ buttons/login/btn_login.png':'Images/New/buttons/login/ btn_login_disabled.png'; /script Any kind of help would be appreciated, thanks. --~--~-~--~~~---~--~~ 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
[wtr-general] Re: Clicking a javascript image
Hmmm...I didn't think about using link and that did work. Thanks for your help On Dec 2, 10:37 am, Darin Duphorn [EMAIL PROTECTED] wrote: Looks like it's a link. Are you using link or image? -Original Message- From: watir-general@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jim Sent: Tuesday, December 02, 2008 11:35 AM To: Watir General Subject: [wtr-general] Clicking a javascript image I am having problems clicking a javascript button. Below is the code used for the button: a href=Javascript:doPost(document.pageForm, 'Update.m'); title=View Hotelsimg src=images/Arizona/button_viewhotels.gif width=190 height=83 alt=View Hotels class=arrow //a If I attempt to click the button using the title or alt, it returns an error saying it cannot be found. Any help with clicking this button (link) will be greatly appreciated. thx- 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---