Page 1 of 2

dataGrid Values validation

Posted: Wed Apr 07, 2010 6:47 pm
by rj-nora
Good afternoon i'm testing Ranorex Studio 2.2 Trial version and at this moment i need to validate if a dataGridValues has 24 lines and 3 columms in a .NET application.

I'm in an internship to complete my graduation on Computer Engineering, and i´ll have to create an automation test platform to automate Manual Test Cases for new releases on Critical Manufacturing company.

´With the validate button on record mode, Ranorex doesn't provide me the contents of a dataGridValues.
It is because i´m using the Trial version?

I need to validate the values of that DataGridValues one by one or exist any other option to do that?

I can validate that if the DataGrid has a certain number of lines and columms without using scripts?If not can you provide me an possible library to do that?



I have a litle hurry because at this time i need to choose which tool i'll use to the internship.


Best regards

email: [email protected] or [email protected]

Re: dataGrid Values validation

Posted: Wed Apr 07, 2010 7:07 pm
by Ciege
Use Ranorex Spy to see how the grid is recognized. From there you can write a little code to get the Grid object then you can use Grid.Rows or Grid.Columns to determine the number of rows and columns.

Re: dataGrid Values validation

Posted: Thu Apr 08, 2010 10:46 am
by rj-nora
Ciege can you show me an script example for validate if the dataGridValues has 24 rows and 2 columns please? I haved already read the User Guide chapter Code Actions, I know where i have to do the script but i'm having some problems to do that validation because i don't know how can i get the object named Table_datGridValues and validate the columns or rows.
i have this on UserCode

public static void Validate_Table_dataGridValues1()
{
//Your code here. Code inside this method will not be changed by the code generator.
Report.Info("Validating Exists on item 'FormTact_Chart_4_2_0_0.Table_dataGridValues'.");
//Validate.Exists(repo.FormTact_Chart_4_2_0_0.Table_dataGridValuesInfo);
for(_table_datagridvaluesInfo.Rows

}



Thanck you very much

Re: dataGrid Values validation

Posted: Thu Apr 08, 2010 4:11 pm
by Ciege
Here is a very brief example. With this example and with a valid table object you can iterate through the rows and output their data to the log. This should get you on the right path.

Code: Select all

try
{
 foreach (Ranorex.Row row in RanorexTable.Rows)
 {
  Report.Info("Found row: " + row.Element.GetAttributeValue("AccessibleValue").ToString());
 }
}
catch (Exception e)
{
 Report.Error(e.ToString());
}

Re: dataGrid Values validation

Posted: Thu Apr 08, 2010 11:46 pm
by rj-nora
ciege ranorex launched a error when i implement that code, saying that RanorexTable doesn't exist

Re: dataGrid Values validation

Posted: Thu Apr 08, 2010 11:52 pm
by Ciege
Like I said you need a valid table object.
RanorexTable happens to be the variable name that I used for the table object.
Set RanorexTable to a valid table object using FindSingle or your preferred method of setting the object.

In the code below RanorexFormName is a valid form object that the table lives on. Make sure that is set or use Host.Local.FindSingle instead to search from the desktop.

Code: Select all

Ranorex.Table RanorexTable = RanorexFormName.FindSingle(".//table[@controlname='" + strTableName + "' or @accessiblename='" + strTableName + "' ]", 60000);

Re: dataGrid Values validation

Posted: Fri Apr 09, 2010 11:20 am
by rj-nora
Ciege i've tried several scritps for example "Code Examples"--> General and using the script above(working with 64bit win7)
// Call explorer.exe
System.Diagnostics.Process.Start("explorer.exe");

then i tried first with:
Form fileExplorer = Host.Local.FindChild<Ranorex.Form>("My Computer");
fileExplorer.Activate();
Button closeButton = fileExplorer.FindDescendant<Ranorex.Button>("Close");
closeButton.Click();

and second:
Form fileExplorer = "/form[@title='My Computer']";
fileExplorer.Activate();
Button closeButton = fileExplorer.FindSingle<Ranorex.Button>
("titlebar/button[@accessiblename='Close']");
closeButton.Click();

and the results were 5 errors on the first scritp(Cannot implicitly convert type 'Ranorex.Form' to 'System.Windows.Forms.Form' (CS0029),'Form' is an ambiguous reference between 'System.Windows.Forms.Form' and 'Ranorex.Form' (CS0104),'System.Windows.Forms.Form' does not contain a definition for 'FindDescendant' and no extension method 'FindDescendant' accepting a first argument of type 'System.Windows.Forms.Form' could be found (are you missing a using directive or an assembly reference?) (CS1061)....

on the second script others 5 errors,between (CS0029),(CS0104),CS1061,CS0069 and

Every time i tried to find a form those errors are showed. Can you explain to me whats the problem? I used the Ranorex Spy to find the title or the class name of the form i´m testing this moment and nothing solves the problem.

Re: dataGrid Values validation

Posted: Fri Apr 09, 2010 12:14 pm
by Support Team
There are Form objects both in the System.Windows.Forms and the Ranorex namespace, and obviously you have "using" statements for both namespaces in your script. To correct the compiler error, you can either remove one of the "using" statements or qualify every usage of Form, e.g.:
Ranorex.Form fileExplorer = "/form[@title='My Computer']";
Regards,
Alex
Ranorex Support Team

Re: dataGrid Values validation

Posted: Fri Apr 09, 2010 3:01 pm
by rj-nora
Thank you very much ciege and support team help i finally get this result!

2010/04/09 14:46:24.806 INFO User Found row: 0:00
2010/04/09 14:46:24.816 INFO User Found row: 1:00
2010/04/09 14:46:24.836 INFO User Found row: 2:00
2010/04/09 14:46:24.836 INFO User Found row: 3:00
2010/04/09 14:46:24.856 INFO User Found row: 4:00
2010/04/09 14:46:24.876 INFO User Found row: 5:00
2010/04/09 14:46:24.896 INFO User Found row: 6:00
2010/04/09 14:46:24.906 INFO User Found row: 7:00

whith that script :

Report.Info("Validating columns and rows in datagrid'.");

Ranorex.Form tactform = ("/form[@controlname='TactChart']");
Ranorex.Table RanorexTable = tactform.FindSingle("/form[@controlname='TactChart']/container/container[@controlname='_togglePanel']/tabpagelist/tabpage[@controlname='_tabPageValues']/table[@controlname='_dataGridValues']");

try
{
foreach (Ranorex.Row row in RanorexTable.Rows)
{
Report.Info("Found row: " + row.Element.GetAttributeValue("AccessibleValue").ToString());
}
Report
}
catch (Exception e)
{
Report.Error(e.ToString());
}

Now i want to make the same to the columns count...but i´m using the same script to columns but the programm doesn't counting them...i only change rows to columns,i´m not seeing none error but the program shows Total Columns:0...can you say me why?

Re: dataGrid Values validation

Posted: Fri Apr 09, 2010 7:02 pm
by Ciege
rj-nora wrote:Now i want to make the same to the columns count...but i´m using the same script to columns but the programm doesn't counting them...i only change rows to columns,i´m not seeing none error but the program shows Total Columns:0...can you say me why?
So based on what you have leared so far (i.e. Table.Rows) think you can figure out the *Columns* part of it on your own?

Another hint. Check the installed Ranorex API Documentation for Table.Rows and then check for Table.??? :)

Re: dataGrid Values validation

Posted: Mon Apr 12, 2010 12:26 pm
by rj-nora
Ciege wrote:
rj-nora wrote:Now i want to make the same to the columns count...but i´m using the same script to columns but the programm doesn't counting them...i only change rows to columns,i´m not seeing none error but the program shows Total Columns:0...can you say me why?
So based on what you have leared so far (i.e. Table.Rows) think you can figure out the *Columns* part of it on your own?

Another hint. Check the installed Ranorex API Documentation for Table.Rows and then check for Table.??? :)
Ciege i didn't understand your question i don't know the word "leared", at this moment i want to count Columns of my DataGrid like i did to count rows with your help,but nothing happens.

Re: dataGrid Values validation

Posted: Mon Apr 12, 2010 1:52 pm
by Support Team
rj-nora wrote: at this moment i want to count Columns of my DataGrid like i did to count rows with your help,but nothing happens.
Maybe because there are no columns? Did you check if there are elements for the columns in Ranorex Spy? Ranorex tables do not support columns in all technologies, however, you can get the number of columns by counting the number of cells in the header row or first data row!

Regards,
Alex
Ranorex Support Team

Re: dataGrid Values validation

Posted: Mon Apr 12, 2010 2:20 pm
by rj-nora
Support Team wrote:
rj-nora wrote: at this moment i want to count Columns of my DataGrid like i did to count rows with your help,but nothing happens.
Maybe because there are no columns? Did you check if there are elements for the columns in Ranorex Spy? Ranorex tables do not support columns in all technologies, however, you can get the number of columns by counting the number of cells in the header row or first data row!

Regards,
Alex
Ranorex Support Team
Yes each row has 2 cells!i attached the screen shot of the datagrid..How can i use the loop foreach to count them? Using this methodthe Report info is Total Columns is :0. I need to see how many columns and rows exists..

Ranorex.Form tactform = ("/form[@controlname='TactChart']");
Ranorex.Table RanorexTable = tactform.FindSingle("/form[@controlname='TactChart']/container/container[@controlname='_togglePanel']/tabpagelist/tabpage[@controlname='_tabPageValues']/table[@controlname='_dataGridValues']");

try
{
foreach (Ranorex.Row row in RanorexTable.Rows)
{
Report.Info("Found row: " + row.Element.GetAttributeValue("AccessibleValue").ToString());
}
Report
}
catch (Exception e)
{
Report.Error(e.ToString());
}

Re: dataGrid Values validation

Posted: Mon Apr 12, 2010 4:17 pm
by Ciege
rj-nora wrote:Ciege i didn't understand your question i don't know the word "leared", at this moment i want to count Columns of my DataGrid like i did to count rows with your help,but nothing happens.
Sorry, typo... Learned is what I meant to say...

Re: dataGrid Values validation

Posted: Mon Apr 12, 2010 4:21 pm
by Ciege
rj-nora wrote: Yes each row has 2 cells!i attached the screen shot of the datagrid..How can i use the loop foreach to count them? Using this methodthe Report info is Total Columns is :0. I need to see how many columns and rows exists..
Try doing somthing like this....

Code: Select all

foreach (Ranorex.Cell cell in row.Cells)
{
Report.Info("Found cell: " + cell.Element.GetAttributeValue("AccessibleValue").ToString());
}