Automation with Excel

Ask general questions here.
anujakulkarni
Posts: 29
Joined: Wed Jan 07, 2009 1:15 pm

Automation with Excel

Post by anujakulkarni » Fri Jan 09, 2009 12:22 pm

Hi,

I tried to execute the following example http://www.ranorex.com/blog/wp-content/ ... orV2.0.zip in Ranorex 2.0 Preview version.

The problem is (it may not be a problem) that after executing the first test case (i.e. “Addition”), the systems prompts to ask if we want to save the “Calc2003.xls” file and the automation stops after that. Please let me know if this is as expected.Am I missing something ?

I would also like to know the reliability of “Data driven test automation with Excel” in general.

Cheers,

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Mon Jan 12, 2009 8:23 am

Hi,

The attached excel file is saved in compatibility mode. Could you please rename and save the file using your installed office version? Maybe the "Save as" dialog is caused by using another office version.

The posted example is used to explain the possibilities with Ranorex in combination with Office COM libraries. You can also export your excel data to a simple CSV file, what is much easier to read using the File and StreamReader Namespaces of the .NET Framework.

Christoph,
Ranorex Support Team

anujakulkarni
Posts: 29
Joined: Wed Jan 07, 2009 1:15 pm

Post by anujakulkarni » Mon Jan 12, 2009 11:34 am

Hi Christoph,

Thanks. The "Save As" dialogue issue is resolved. :)

What I am still stuck at is, according to my understanding, the way the "Test1()" method is implemented, it should read all the test cases in the excel file and execute them one after the other(As you know, there are 12 test cases in this case). But the automation stops after the first test case itself!!

Is my understanding of the implementation wrong? Or am I missing something again? :?:

Cheers,

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Mon Jan 19, 2009 9:56 am

Hi,

Did you try to debug the example code? It would be nice if you could tell me where (code line, method name) the code does not work as expected.

kind regards,

Christoph,
Ranorex Support Team

anujakulkarni
Posts: 29
Joined: Wed Jan 07, 2009 1:15 pm

Post by anujakulkarni » Mon Jan 19, 2009 10:38 am

Hi Christoph,

First of all I did the following changes to the code as I was getting some comilation errors. Please let me know if they are as expected.As I am using Ranorex for the first time I don't quite know what is changed in Version 2.0 as compared to version 1.5.
  • Line no.73

    Code: Select all

    Ranorex.Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
    is changed to

    Code: Select all

    Ranorex.Core.Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
    as the line gave me an error
    The type or namespace name 'Keyboard' does not exist in the namespace 'Ranorex' (are you missing an assembly reference?) (CS0234) - D:\Projects\ACS\Ranorex\RanorexStudio Projects\ExcelTestDataConnectorV2.0\MainForm.cs:73,21
    Line No. 82

    Code: Select all

    catch (Ranorex.RanorexException ex)
    is changed to

    Code: Select all

    catch (Ranorex.Core.RanorexException ex)
    as it gave an error
    The type or namespace name 'RanorexException' does not exist in the namespace 'Ranorex' (are you missing an assembly reference?) (CS0234) - D:\Projects\ACS\Ranorex\RanorexStudio Projects\ExcelTestDataConnectorV2.0\MainForm.cs:82,28
    Line No.102

    Code: Select all

    throw new Ranorex.RanorexException("Calculator application form not found!");
    was changed to

    Code: Select all

    throw new Ranorex.Core.RanorexException("Calculator application form not found!");
    as it gave an error
    The type or namespace name 'RanorexException' does not exist in the namespace 'Ranorex' (are you missing an assembly reference?) (CS0234) - D:\Projects\ACS\Ranorex\RanorexStudio Projects\ExcelTestDataConnectorV2.0\MainForm.cs:102,23
    Line No.119

    Code: Select all

    Ranorex.Validate.Attribute(text, "text", testData.Outputs[0] + ", ");
    was changed to

    Code: Select all

    Ranorex.Core.Validate.Attribute(text,"text",testData.Outputs[0] + ",");
    as it gave an error
    The type or namespace name 'Validate' does not exist in the namespace 'Ranorex' (are you missing an assembly reference?) (CS0234) - D:\Projects\ACS\Ranorex\RanorexStudio Projects\ExcelTestDataConnectorV2.0\MainForm.cs:119,25
I was under the impression that after this all the tests in the excel file should be executed one after the other as all of them are passing.But unfortunately, the code is throwing an exception at the "validate" statement at Line no.119 and hence going to the "catch" block and eiting the test due to the "finally" block.

Please let me know if I am missing something.

I will also like to know how I can continue running the remaining test even if some test fails in between.In other words, how can I execute the "finally" block at the end after all the tests have been executed?

Cheers,

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Mon Feb 02, 2009 9:25 am

Hi

Could you please replace the code line no. 119 with following:

Code: Select all

Ranorex.Validate.Attribute(text, "text", new Regex(testData.Outputs[0] + ",|."));
Additionally, it is required to add following using statement:

Code: Select all

using System.Text.RegularExpressions;
best regards,

Christoph
Ranorex Support Team