Page 1 of 1

Declare an Item as a new variable

Posted: Thu Sep 01, 2016 11:10 am
by bta
Hi,
I have the following problem:

I our SUT there are a window that contains three tables (with diférents path).
In a code module, I would use one of these three tables (switch a condition) :
Ranorex.Table tableau = null;
			
			switch (_numero_de_tableau)
			{
				case "1" :
					 tableau = repo.Superviseur_Logistique.MainGrid.Tableau_Cde_Frs_et_OF;
				case "2" :
					 tableau = repo.Superviseur_Logistique.MainGrid.Tableau_Stock;
				case "3" :
					 tableau = repo.Superviseur_Logistique.MainGrid.Tableau_Cde_Client_et_OF;
			} 
                         tableau.Cell_var_txt_ChildIndex.Click();
at the execution of the code, I got the following error :

Impossible de convertir implicitement le type 'GestionCommerciale.GestionCommercialeRepositoryFolders.Tableau_Cde_Frs_et_OFFolder' en 'Ranorex.Table' (CS0029)

Impossible de convertir implicitement le type 'GestionCommerciale.GestionCommercialeRepositoryFolders.Tableau_StockFolder' en 'Ranorex.Table' (CS0029) -

Impossible de convertir implicitement le type 'GestionCommerciale.GestionCommercialeRepositoryFolders.Tableau_Cde_Client_et_OFFolder' en 'Ranorex.Table' (CS0029) -


Thank you in advance for your help

Re: Declare an Item as a new variable

Posted: Fri Sep 02, 2016 9:33 am
by RobinHood42
Hello bta,

The exception is thrown whenever you try to assign an object with a wrong data type. Your repository items aren't of type "Ranorex.Table" and cannot implicitly casted and assigned to your object: "Ranorex.Table tableau"

Please check the data type of your repo items.

Hope this helps.

Cheers,
Robin

Re: Declare an Item as a new variable

Posted: Fri Sep 02, 2016 10:32 am
by bta
Thank you RobinHood42 for your reply

You are right !! indeed basically they were tables, but I forgot that I converted them to "Rooted Folder" in order to add items (rows, cells,...). So that's why their type is no longer "Ranorex.Table".

I don't Know if there is a general type of "Rooted Folder" (like "Ranorex.Folder" or "Ranorex.RootedFolder",...)

Any ideas please?

Re: Declare an Item as a new variable

Posted: Fri Sep 02, 2016 1:16 pm
by RobinHood42
Hi,

this should not cause any issues. Please use Ranorex Spy to track the elements once again, please check out their "PreferredCapability". Spy -> Advanced Tab -> General
ElementPreferredCapability.png
If you still have issues finding the correct adapter type, please upload a screenshot or Ranorex snapshot of the specific element.

Cheers,
Robin

Re: Declare an Item as a new variable

Posted: Fri Sep 02, 2016 2:53 pm
by krstcs
For rooted folders, you need to use the "Self" property.


RanorexTable table = myRootedFolder.Self;

Re: Declare an Item as a new variable

Posted: Fri Sep 02, 2016 4:03 pm
by bta
Hi Robert,

Thanks again for your help.

When I check the item with Ranorex Spy, it is indeed a table, as you see in the screenshot as you see bellow :
Capture.PNG
[/size]
But it does not work when I declared the variable with like Ranorex.Tableas
I don't know if the cause of the issue is the fact of converting the table to rooted folder ! :?:

(you will also find attached the Snapshot of one table)


Greeting,
Bilel

Re: Declare an Item as a new variable

Posted: Fri Sep 02, 2016 4:18 pm
by krstcs
Please read my post above your last one.

Re: Declare an Item as a new variable

Posted: Mon Sep 05, 2016 9:31 am
by bta
Hi krstcs
Thank you for your reply.

Your suggestion (the self property) solved my first problem (implicitly convert the type "RootedFolder" to "Ranorex.Table").
But the problem now is that by declaring the variable as "Ranorex.Table" (while it is "RootedFolder"), it is not possible to access to the children Items in my Repository as you will see in the code, and the Errors, below :

Ranorex.Table tableau = repo.Superviseur_Logistique.MainGrid.Tableau_Cde_Frs_et_OF.Self;
			switch (_numero_de_tableau)
			{
				case "1" :
					tableau = repo.Superviseur_Logistique.MainGrid.Tableau_Cde_Frs_et_OF.Self;
				case "2" :
					tableau = repo.Superviseur_Logistique.MainGrid.Tableau_Stock.Self;
				case "3" :
					tableau = repo.Superviseur_Logistique.MainGrid.Tableau_Cde_Client_et_OF.Self;
			}
     repo.ChildIndex = tableau.Entete_du_tableau.HeaderText.Element.Parent.Parent.Parent.ChildIndex.ToString();
				Validate.IsTrue(tableau.Lignes_du_tableau.Cellule_var_ChildIndex.Text == donnee[2]);


ERRORS :

'Ranorex.Table' ne contient pas une définition pour 'Entete_du_tableau' et aucune méthode d'extension 'Entete_du_tableau' acceptant un premier argument de type 'Ranorex.Table' n'a été trouvée (une directive using ou une référence d'assembly est-elle manquante ?)

'Ranorex.Table' ne contient pas une définition pour 'Lignes_du_tableau' et aucune méthode d'extension 'Lignes_du_tableau' acceptant un premier argument de type 'Ranorex.Table' n'a été trouvée (une directive using ou une référence d'assembly est-elle manquante ?)



Greeting,

Bilel

Re: Declare an Item as a new variable

Posted: Tue Sep 06, 2016 11:00 am
by bta
I don't know if I was clear in my question ...
Let me explain :
As you will see bellow, In my repository, I have three tables converted to "ROOTED FOLDER" :
Capture.PNG
In a code module I want to use one of these three tables, switch a condition.
So for that, I would declare at the beginning a general variable of type "ROOTED FOLDER".Then, depending on the condition, I would like to be able to use this variable (Folder), as well as items in this folder :
Capture1.PNG
Do not hesitate if you have any suggestions

Thank you for advance for your help