Problem with scripting a dynamic cell list in .net app

Class library usage, coding and language questions.
nooneimportant
Posts: 1
Joined: Mon Jun 12, 2017 12:20 pm

Problem with scripting a dynamic cell list in .net app

Post by nooneimportant » Wed Jun 14, 2017 2:01 pm

Hello everyone, i’m having a huge problem with preparing a script, and if it’s possible i would love to get some help. I will try to describe it as clear as i can, at first i will write my scenario down, and after that i will attach some screenshot of my application (i’m rly sorry for my paint ability, but i needed to hide some personal data).
It’s .net app (prolly version 1.), and i’m using Ranorex 7.1.

First of all my business path is kinda complex, and i’m having a huge problem with one part. There’s a moment when i need to choose one debt to process it further and start the debt recovery process, but after doing it, in the next form there’s a possibility of an error, when application won’t allow to accept this (for example when the debt amount is not high enough to do it etc.).
Since i’m not able to disable this verification by app, i need to prepare a script as much flexible as it’s possible and prepare it for this error situation.
So there are some screenshots of these problematic forms:
„First_form.png”:
Image
It looks like i have some problem with adding image, here's direct link: imgur.com/uQmT2P1
- Content of this form depend on the criteria i choose in the previous searching form, this list is dynamic. I choose debts i want to process further by clicking on the checkbox in the column i’ve marked with blue colour.

„Second_form_starting_tab”:
Image
imgur.com/8gRFIKx
Here i have my choosed debts from the previous form, and here we can see if there’s an error (column marked with red colour). Here it’s empty and i can accept this process for next stage. There are no pop-up information when an error occurs, there is just an error picture in this column for specific row. To accept this process i need to mark the checkbox marked with blue colour and press the button i’ve marked with green.

„Second_form_approved_process_tab”:
Image
imgur.com/AEaXdam
- It’s the same form like in the previous ss but next tab. When application won’t find any errors, it will change the stage of this debt recovery process, moving my debt from the previous tab to this one.

So after this introduction i’m thinking that i need to create something like this:
I need to find all checkboxes from the first screenshot, i can do it with this path:
/form[@controlname='FrmZadluzenia']/container[@controlname='pnlGrid']//row[@accessiblename~'Row']/cell[@accessiblename='Wybór row 0']
and put them into the list:
IList<Cell> all_debts = Host.Local.Find<Cell>("/form[@controlname='FrmZadluzenia']/container[@controlname='pnlGrid']//row[@accessiblename~'Row']/cell[@accessiblename='Wybór row 0']");
Then i would like to take one of the found cells, to process it further. IS this line proper for this action?
var choosen_debt = all_debts.Take(1);
Then process it further to the situation i’ve presented on the third screenshot.
But there’s a problem with an errors that may occurs, so i’m thinking i need to somehow shuffle my list with all checkboxes and create a loop. I found something like this:
static class Extensions
    {
        public static void Shuffle<T>(this IList<T> list, Random rnd)
        {
            for(var i=0; i < list.Count; i++)
                list.Swap(i, rnd.Next(i, list.Count));
        }
        
        public static void Swap<T>(this IList<T> list, int i, int j)
        {
            var temp = list;
            list = list[j];
            list[j] = temp;
        }
    }


So overall i’m thinking about it:
partial class Wyszukiwanie_zadluzen_podstawowe
    {
        /// <summary>
       /// </summary>
        private void Init()
        {
            // Your recording specific initialization code goes here.
        }

        public static void Wybor_zadluzenia()
        {
        	while(true)
        	{
        		try
        		{
        			IList<Cell> all_debts = Host.Local.Find<Cell>("/form[@controlname='FrmZadluzenia']/container[@controlname='pnlGrid']//row[@accessiblename~'Row']/cell[@accessiblename='Wybór row 0']");
        			all_debts.Shuffle();
        			var choosen_debt = all_debts.Take(1);
        			// then all next merged steps i need to make, to process it further (situation presented on third screenshot)
        			// at the end i'm thinking about using "if" statemant and validate if there's a row in my form i've presented of the third screenshot, if it’s existing then use break;
        		}
        		catch
        		{
        			//in case of an error that may occurs, here i would put all steps i need to make to return from the third form to the search results i've presented on the first screenshot
        		}
        	}
        	        	
        }
        
    }
	
	static class Extensions
	{
		public static void Shuffle<T>(this IList<T> list, Random rnd)
		{
			for(var i=0; i < list.Count; i++)
				list.Swap(i, rnd.Next(i, list.Count));
		}
		
		public static void Swap<T>(this IList<T> list, int i, int j)
		{
			var temp = list;
			list = list[j];
			list[j] = temp;
		}
	}



I think that with this loop usage i’m kinda prepared for errors, if there will be one it won’t make to the break statement and start it again choosing another cell thanks to the shuffle method.

So guys what do you think about this solution, first of all is it possible to create a script for my business scenario?
Also i would like to admit that i’m only starting programming so there may be mistakes, but please point them so i can learn :)

I would like to thank you for any responds i may receive.

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

Re: Problem with scripting a dynamic cell list in .net app

Post by odklizec » Tue Jun 20, 2017 7:27 am

Hi,

Please upload a Ranorex snapshot(s) related to your problem. The thing is, that screenshots are not very useful here. And because your problem appears to be quite complex, without (at least) snapshots, it's next to impossible to offer a reasonable suggestion. Ideally, post snapshots and a small sample Ranorex solution, so we don't have to recreate it from scratch. Thanks.
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

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Problem with scripting a dynamic cell list in .net app

Post by Vaughan.Douglas » Tue Jun 20, 2017 3:36 pm

First of all, does this list change once you've completed your process?
First_form.png
Processing an item will likely change the collection in your loop which will cause you all sorts of problems. You may be better off with a Do While loop.

Next, I'm not clear on the progression of these next two screens.
Does this screen ALWAYS appear or only appear when there are errors?
Second_form_starting_tab.png
Does this screen always appear or only after the error has been resolved?
Second_form_approved_process_tab.png
Finally, when you upload a pucture, just place you're cursor where you want the picture to go and click "Place Inline"
You do not have the required permissions to view the files attached to this post.
Doug Vaughan