Automation Locking MessageBox

Ask general questions here.
pere
Posts: 12
Joined: Mon May 25, 2009 3:32 pm
Location: Barcelona

Automation Locking MessageBox

Post by pere » Wed May 27, 2009 5:49 pm

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!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu May 28, 2009 9:09 am

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

pere
Posts: 12
Joined: Mon May 25, 2009 3:32 pm
Location: Barcelona

Bug with Web plugin

Post by pere » Thu May 28, 2009 9:28 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu May 28, 2009 10:07 am

Strange,
could you please send a Ranorex snapshot of your Website under Test to support_at_ranorex.com.

Regards,
Christian
Ranorex Support Team

pere
Posts: 12
Joined: Mon May 25, 2009 3:32 pm
Location: Barcelona

Post by pere » Thu May 28, 2009 10:28 am

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu May 28, 2009 12:28 pm

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

pere
Posts: 12
Joined: Mon May 25, 2009 3:32 pm
Location: Barcelona

Post by pere » Thu May 28, 2009 2:08 pm

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...

pere
Posts: 12
Joined: Mon May 25, 2009 3:32 pm
Location: Barcelona

Post by pere » Tue Jun 02, 2009 7:51 am

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Tue Jun 02, 2009 2:58 pm

(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

pere
Posts: 12
Joined: Mon May 25, 2009 3:32 pm
Location: Barcelona

Post by pere » Tue Jun 02, 2009 3:32 pm

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!