Page 1 of 1

Automation Locking MessageBox

Posted: Wed May 27, 2009 5:49 pm
by pere
Hi,
I am automating a web page. Everything goes fine until I press a 'Delete' button that pops up a confirmation Message Box in JavaScript:

Code: Select all

function confirmDelete() {
      	res = window.confirm("Are you sure you want to delete this record?")
  	    if (res) {
  	    	return true;
  	    } else { 
  	    	return false; 
  	    }
 	  }
When a button.PerformClick() is executed on that 'Delete' button, the thread gets locked. So the following code, that locates the MessageBox to perform a click on the 'OK' button, never executes.
I've managed to solve it by using another thread that closes teh message box by confirming the deletion :

Code: Select all

Form confirmationForm = Host.Local.FindSingle("/form[@title='Message from webpage']", new Duration(10000));
Button okButton = confirmationForm.FindSingle("button[@text='OK']", new Duration(10000));
Keyboard.Press(System.Windows.Forms.Keys.Enter, new Duration(100));
The questions are:
1. Is there any reason why the thread that is performing the automation tasks gets blocked? (The thread is a STA thread, not the UI thread). Can I do anything so the thread does not get blocked on the message box, so I can continue the automation and close the MessageBox?
2. From this secondary thread I use to workaround the issue, when I obtain the 'OK' button, I cannot execute the Press method on it, because it raises a Ranorex.ActionFailedException, with message {"Action 'press' failed on element '{Button:OK}'."}. The inner exception gives this additional information {"The operation is not supported."}. I've managed to solve this by using a Keyboard.Press. However, I'd prefer to avoid using Keyboard or mouse. Why this code is not working when executing the Press method?

Code: Select all

Form confirmationForm = Host.Local.FindSingle("/form[@title='Message from webpage']", new Duration(10000));
Button okButton = confirmationForm.FindSingle("button[@text='OK']", new Duration(10000));
okButton.Press();
Thanks!

Posted: Thu May 28, 2009 9:09 am
by Support Team
hello pere,
instead of PerformClick() use the Click() member method. PerformClick is called in the thread of javascript which blocks the automation until the button of the message box was clicked.

Regards,
Christian
Ranorex Support Team

Bug with Web plugin

Posted: Thu May 28, 2009 9:28 am
by pere
Well, I'm not using any Click method because the mouse never points to the right place. When I use the click, the mouse moves approx. 180-190 pixels to the left and 120-130 pixels to the top of the right place, so it clicks in the air...
Within RanorexSpy, if I highlight the elements of the DOM, the surrounding boxes appear always displaced to the top and left...
Is this a bug of Ranorex Web?

Thanks

Posted: Thu May 28, 2009 10:07 am
by Support Team
Strange,
could you please send a Ranorex snapshot of your Website under Test to support_at_ranorex.com.

Regards,
Christian
Ranorex Support Team

Posted: Thu May 28, 2009 10:28 am
by pere
Hi,
Unfortunately we are a healthcare company and we cannot send any information outside because of patient data protection. However, I'm experiencing this same problem with other webs. I'll send you a snapshot from your own web and a sample screenshot of what the Spy highlights on the screen.

Posted: Thu May 28, 2009 12:28 pm
by Support Team
You have really strange coordinates in your element tree. I`ve tested your setup (i suppose XP, Ranorex 2.0, IE8) and i couldn`t reproduce the issue. There`s something weird on your machine.

suggestion:
- install Ranorex2.1
- do you have a IE8 beta installed or something?
- do you use custom DPI settings?

Regards,
Christian
Ranorex Support Team

Posted: Thu May 28, 2009 2:08 pm
by pere
We bought Ranorex just three weeks before 2.1 was on the market, and my licensing does not include 2.1....

And no, I don't have IE8 beta, and use standard 96 DPI (though I changed it some time ago). But now it's 96 again, so...

Posted: Tue Jun 02, 2009 7:51 am
by pere
softomania wrote:The solution is very useful.


Software testing tutorial
I'm sorry but I cannot find any related topic in the web you mention. Can you point me to the right place in the web? Thanks.

Posted: Tue Jun 02, 2009 2:58 pm
by Support Team
(Deleted spam message above)

Pere,
We identified a possible problem related to yours (wrong coordinates) with another customer. Does your site have any embedded frames / iframes ?

If it does, we can probably provide a solution with the 2.1.1 maintenance release, scheduled to be released by the end of the week.

Michael
Ranorex Team

Posted: Tue Jun 02, 2009 3:32 pm
by pere
Yes, it does. I'm using now the Keyboard to perform the click, because I'm lucky and it's the default button of the dialog...
Great if you can fix it so soon!