Use baseclass and where is "exist"?

Class library usage, coding and language questions.
Stas_Tserk
Posts: 19
Joined: Tue Jan 27, 2015 4:09 pm

Use baseclass and where is "exist"?

Post by Stas_Tserk » Wed Feb 17, 2016 11:54 am

Hello!
First of all, I am using Ranorex 5.4.4. I automate big MS Access database with a lot of forms. I am trying to find the best solution for me.
What I am automation:
1. Open form in access.
2. Check that after opening form is enabled.
3. Close form -> go next form

My issue here: sometimes some forms cannot be opened and I have a popup window "Error, cannot find table" or something else. Text of messages can be different.

Can you help me with this questions:
1. After any form opening I should check for popup window. How to do it? I add to repository popup window path, but in code I cannot write "window.exist", I have only "enabled" and others, but it isn't the same. Use try/catch? Not the best way, I think.

2. How to use base class? I record test, add "User Code" element, open code and inherited from baseclass, where I already have method from my question one, but I didn't find how to call it.
Btw can we avoid this inherited for all recorded tests classes? I have a lot of forms and it can keep my time. If no way - I am ok, it isn't general.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Use baseclass and where is "exist"?

Post by odklizec » Wed Feb 17, 2016 1:37 pm

Hi,

1) The problem like this is best to handle with code described here (Handling unexpected dialogs):
http://www.ranorex.com/support/user-gui ... html#c4678

The problem of this solution is, that it runs in a separate thread and it does not pause the main test thread, which means Ranorex may continue with some steps (and fail) before the dialog is 'handled' from popup watching thread.

Another possibility is to add user code action right after the 'Open Form' action, with custom loop (with timeout) which waits for the appearance of given dialog. The problem is that you most probably don't know the best 'timeout'. Let's say you define 30sec timeout but the popup appears at 31sec? ;) So using popup watcher may be the best solution after all?

2) As for accessing methods form base class, have you checked this Ranorex blog article:
http://www.ranorex.com/blog/custom-smar ... readAction
Basically, you need to use 'inheritance' in each user code module from which you want to call base class mehtods. After that you can simply access the base class methods by typing their name in User Code (they should be visible in the list of available methods). Eventually, you can add the UserCode action to recording table and you should be able to select the appropriated method in the list of methods available for just added User Code action. It's all described in the above blog post.

Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration