Ranorex

Ask general questions here.
OPT-Liuxm
Posts: 31
Joined: Sat Jan 11, 2020 3:58 am

Ranorex

Post by OPT-Liuxm » Sat Mar 28, 2020 4:20 am

Hello, everyone.
Excuse me, I'd like to ask you some questions.
I want to do a Monkey Test with Ranorex.
I asked some friends online.
They told me to use API programming to get all the elements on the page, number them, use random Numbers, and click.
But I don't know API programming.
So now I don't know how to get the elements on the test program and then click randomly, okay.
Could you please tell me the operation?
Thank you all.
Wait for your answer

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

Re: Ranorex

Post by odklizec » Sat Mar 28, 2020 10:26 am

Hi,

I’m afraid, a bit of programming will be definitely required for this kind of test. Could you please post a Ranorex snapshot (NOT screenshot) of the page with elements? So we can evaluate your UI and eventually suggest a solution. Without, at very least, snapshot, there is not much anyone here can do or suggest.
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

OPT-Liuxm
Posts: 31
Joined: Sat Jan 11, 2020 3:58 am

Re: Ranorex

Post by OPT-Liuxm » Mon Mar 30, 2020 4:32 am

Thank you for your reply.
If you need to program, do you program directly on Ranorex Studio?Or do you need other programming software?What are the programming languages?
Our software is made with QT.
Please understand that the Ranorex snapshot of the software cannot be provided at present because the software is not released.
I took a snapshot of the Ranorex demo application. Any Suggestions if I want to MonkeyTest this demo application?
I'm sorry to disturb you. I'm looking forward to your reply. Best wishes.
Attachments
DEMO.rxsnp
(42.08 KiB) Downloaded 5 times

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

Re: Ranorex

Post by odklizec » Mon Mar 30, 2020 9:20 am

Hi,

Ranorex is a fully featured development IDE, supporting C# and VB .NET languages. So you don't need to use another app.

From the snapshot you posted I see that you are using an outdated Ranorex version 8.1.1. This version is no longer supported and you must update to something more recent, for example latest 9.3.1. The version you are using is simply not supported anymore and any example I or anyone here might suggest may be not compatible with your version. So please, update your Ranorex.

As for your problem, I'm afraid that I cannot provide you with complete solution. And without knowing more details about your specific app and what exactly you want to achieve (just clicks on buttons or also filling inputs), it would be impossible to suggest something reliable. To be quite honest, I personally think that monkey test is a very low informative value and is more or or less waste of time. But it's your app and your (company) decision ;)

So, what you need to do first, is to create xpath of all elements you want to eventually click in random order. In demo app you posted, there is number of elements to click, but let's say you want to click individual page tabs (from Introduction to Object identification). So the xpath returning all "tabs" objects looks like this (add it to repository):
/form[@controlname='RxMainFrame']/?/?/tabpage[@accessiblerole='PageTab' and @visible='true']
The result in spy looks like this:
RxDemoApp_tabs.png
RxDemoApp_tabs.png (80.76 KiB) Viewed 279 times
Now you need to write a code to click individual tabs in random order. As an example, you can use code from this sample page:
https://www.ranorex.com/help/latest/han ... oryelement
This particular example simply goes through the list of available elements, provided by given xpath and takes a screenshot of each element. But you need to click it, which requires only a simple change.
Here is a basic code, which will go through the list or tab elements, returned by repo element xptah, and click each single tab...

Code: Select all

private void ClickPageTabs(RepoItemInfo repoElement)
{
    // Create a list of adapters using the "Info" object
    IList<Ranorex.PageTab> tabList = repoElement.CreateAdapters<Ranorex.PageTab>();
    // go through the list and click each element
    foreach (Ranorex.PageTab tabItem in tabList) 
    { 
        tabItem .MoveTo(); 
        tabItem .Click(); 
    }
}
However, because you want click elements in random order, it will require some further changes ;)

Code: Select all

public static void ClickPageTabs(RepoItemInfo repoElement)
{
    // Create a list of adapters using the "Info" object
    IList<Ranorex.TabPage> tabList = repoElement.CreateAdapters<Ranorex.TabPage>();
    // create random seed
    System.Random rand = new Random(System.DateTime.Now.ToString().GetHashCode());
    // go through the list and click each element in random order
    while (tabList.Count > 0)
    {
    	//get random tab number
        int index = rand.Next(0, tabList.Count);
        tabList[index].MoveTo();
        // click random tab
        tabList[index].Click();
        //take screenshot of random tab
        Report.Screenshot(tabList[index]);
        // remove just clicked tab from the list of tabs (to not click it again)
        tabList.RemoveAt(index);
    }        	
}
So this is the basic concept of clicking UI elements in random order. To click more UI elements, you will have to adapt the xpath, to included other UI elements. Eventually, you may need to improve the code, in case you want not just click the elements but also fill the inputs. 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

OPT-Liuxm
Posts: 31
Joined: Sat Jan 11, 2020 3:58 am

Re: Ranorex

Post by OPT-Liuxm » Mon Mar 30, 2020 12:58 pm

Thank you for taking time out of your busy schedule to reply to my message and provide me with help.

As you said, the version of Ranorex I used is 8.1.1, which was purchased by the company last year and has not been updated yet.

My supervisor just wanted me to use Ranorex to automatically and randomly click on the application under development and check whether it crashed. There was no need to go further to do the MonkeyTest.

At the time, I thought that Ranorex could take all the elements on the page, randomly set the sequence number of the elements, and run the click.

It seems to be programmed to implement it.

I have seen the code you edited, is it the C# development language?

Finally, dear Ranorex Guru, could you use the demo application to do a random click and package it for me? I want to really understand this.

Thank you for your timely reply, wish you a happy life, thank you. :D :D :D

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

Re: Ranorex

Post by odklizec » Mon Mar 30, 2020 2:45 pm

Hi,

You are welcome. I'm afraid, there is no such a think in Ranorex like automatic/randomized clicks of elements. So as mentioned, it must be coded. I'm attaching the sample solution. And yes, it's C# based.

As for randomly clicking the app in an effort to make it to crash, I think it's a complete waste of time and energy ;) But your boss probably knows why he asks for such a meaningless test? :D
Attachments
MyTest4.zip
(19.87 KiB) Downloaded 6 times
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

OPT-Liuxm
Posts: 31
Joined: Sat Jan 11, 2020 3:58 am

Re: Ranorex

Post by OPT-Liuxm » Tue Mar 31, 2020 2:14 am

Hello,

Thank you very much for your help and prompt reply.

It seems that I need to learn the C# language. Ha, ha, ha.

I think a MonkeyTest is a test that takes a long time and gets low value.So I thought of using Ranorex to automatically do MonkeyTest.
Is the version of Ranorex you are using the latest? 9.3?
I feel very happy to contact you, thank you.
If you're on facebook or instagram, I'll be sure to follow you.Ha, ha, ha.

Best wishes to you.

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

Re: Ranorex

Post by odklizec » Tue Mar 31, 2020 8:13 am

Hi,

You are welcome. And yes, despite of what Ranorex (or any other TA tool) marketing materials says, a bit of coding knowledge is ALWAYS required when it comes to TA. Of course, it's easy to start with "record and replay", but at some point, you will always need to perform "loop" here or use "condition" there. And doing some things via recordings is simply way too complicated or not possible at all :D

Most recent Ranorex is 9.3.1. And I'm afraid, I'm not using Instagram and FB only rarely for private stuff in czech language. So I guess nothing useful for you? :D
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

OPT-Liuxm
Posts: 31
Joined: Sat Jan 11, 2020 3:58 am

Re: Ranorex

Post by OPT-Liuxm » Tue Mar 31, 2020 9:00 am

Hi,
I agree with your idea.
With Ranorex, pure "record and playback" is just the foundation.Slowly learn about the use of Ranorex.

No one in my department knows how to Ranorex. I'm still a rookie and a recent college graduate.
Only learned the content of Ranorex website

I have enjoyed communicating with you.
Thank you for your reply and best wishes.

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

Re: Ranorex

Post by odklizec » Tue Mar 31, 2020 10:21 am

Hi,

Just go step by step and start with simple test cases, then continue with more complex scenarios. Keep your repo clean and tidy and name recordings (repo element, test cases, etc...) with clear names. And don't add more than 10 actions in one recording! Huge recordings makes them much less re-usable. These simple rules, and some more, will make your TA life much easier ;) Good luck!
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

OPT-Liuxm
Posts: 31
Joined: Sat Jan 11, 2020 3:58 am

Re: Ranorex

Post by OPT-Liuxm » Thu Apr 02, 2020 4:58 am

Hi, :D
I'm sorry to disturb you again.
I still need your help.

This is my file. Could you write a C# code with a random click from my file?There are still errors in my writing.
Thank you very much.

Waiting for your reply, best wishes.
Attachments
MyTest1.7z
(91.8 KiB) Downloaded 5 times

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

Re: Ranorex

Post by odklizec » Thu Apr 02, 2020 7:40 am

Hi,

I'm afraid, I don't have a clue what you would like to help with? Your project contains just Run action with application I'm not possessing and that's all? ;)
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

OPT-Liuxm
Posts: 31
Joined: Sat Jan 11, 2020 3:58 am

Re: Ranorex

Post by OPT-Liuxm » Thu Apr 02, 2020 8:37 am

Hi,
I am sorry.
First of all, thank you for your reply.

Yeah, I got a little QT program from my friend.
There are only a few buttons and input fields on this program.
If I want to do a random click or a random type on it with Ranorex.
Oh, no.The program is a little big.
There are always so many stumbling blocks in my way of study....
Other mail delivery?
I'm sorry to have been bothering you

Best wishes for you.
Attachments
MyTest.7z
(14.66 KiB) Downloaded 4 times
Folder_Control.rxsnp
(30.64 KiB) Downloaded 5 times

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

Re: Ranorex

Post by odklizec » Thu Apr 02, 2020 9:13 am

Hi,

Try to use a 3rd party file sharing service (dropbox, onedrive, google drive, etc...). However, I think you will have to try it yourself first, with the sample I provided. If for nothing else, it's somewhat hard to work with UI, which is not even in English ;)

Basically, you need to use this xpath, to collect all buttons and inputs, which you can then click or type into in random order.
/form[@name='MainWindow']/?/?/*[@type='QLineEdit' or @type='QPushButton' ]
PS:
Out of sheer curiosity, I adapted your sample project with my random code. It may or may not work with your sample app ;)
MyTest1.zip
(140.28 KiB) Downloaded 5 times
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

OPT-Liuxm
Posts: 31
Joined: Sat Jan 11, 2020 3:58 am

Re: Ranorex

Post by OPT-Liuxm » Fri Apr 10, 2020 9:00 am

Hi, long time no see.
Please forgive me for being a little busy recently and not replying to your email. I'm sorry.
I have read your sample and understood some ideas. I think it is very helpful to me. Thank you.

I am learning slowly. I hope you can help me with the problems I can't solve.
Best wishes for you.
Thank you.