SlideShare ist ein Scribd-Unternehmen logo
1 von 6
Downloaden Sie, um offline zu lesen
Ranorex Tutorial
                                                                                      Spirit Du
                                                                    March 27th, 2007 Ver. 1.1.4


Contents 
About this Document....................................................................................... 1
Ranorex Installation and Setup ...................................................................... 1
Tutorial – Test SimpleCalculator using Ranorex............................................ 2


About this Document
     NUnit framework is very useful for testing a small piece of program
without GUI. But how do we test the correctness of GUI interactions? This
document introduces a tool Ranorex, which can “simulate” user
interactions and perform assertions. We will integrate this tool with the
NUnit framework to test the SimpleCalculator developed in your
homework.


Ranorex Installation and Setup
     Ranorex is a Windows GUI test and automation Library for C++,
Python, and the .Net languages. The user (e.g. the software tester)
should use the functionalities of the programming languages like Python
or C# as a base, and enlarge it with the GUI automation functionality of
Ranorex. Before starting this tutorial, it needs to get the Ranorex installer
form the URL:
     http://www.ranorex.com/download/
     Download the free edition and execute the installer with default
settings. After installation 1 , copy the file: RanorexCore.dll 2 from [Ranorex
Location] 3 BinNet2.0 and then paste to [Windows] 4 system32 as
global library cache 5 .

1  You don’t have to install the Ranorex. But you do need to do this set up step by
yourself because there is no such file in system32 folder in the computer lab.
2 Any project developed with Ranorex will run with RanorexCore.dll
3 The default location is C:Program FilesRanorex-1.1.0
4 The default location for Windows XP/2000 is C:WinNT
5 It will facilitate the development without denoting the location of RanorexCore.dll in

each project.

Windows Programming Tutorial – Ranorex                                                                 - 1-
Tutorial – Test SimpleCalculator using Ranorex
Step1.Open the existing Visual Studio Solution which contains your
      calculator.
         As shown in Figure 1, SimpleCalculator is the project developed in the previous
         homework which is contained in Windows Programming solution.




                 Figure 1 The Solution contains SimpleCalculator project


Step2.Add a class: GUITester into existing project.




                           Figure 2 Add a new class: GUITester


Step3.Add RanorexNet references 6




                            Figure 3 Add Ranorex reference


Step4.Add using declarations
         Open the GUITester.cs and add the following two declarations.


6   Default location: C:Program FilesRanorex-1.1.0BinNet2.0

Windows Programming Tutorial – Ranorex                                             - 2-
using NUnit.Framework;
    using Ranorex;

Step5.Declare a test fixture and a member data
        This is similar to the previous tutorial; add a test fixture attribute before the class
        declaration. Then, change the visibility to public and add a new field: _testee.

    namespace SimpleCalculatorGUITests {
        [TestFixture]
        public class GUITester {
              Form _testee;
        }
    }



Step6.Use the Ranorex to activate SimpleCalculator in setup method 7 .
        Add a member method, setup(), into GUITester class. Note that the [SetUp]
        attribute and the value of application string must be the same as the title
        (name of the .exe file) of your simple calculator.

    [SetUp]
    public void setUp() {
        // Project Name or executable file name
        string application = "SimpleCalculator";
        Application.SleepTime = 50;
        Mouse.MoveTime = 10;
        Application.Start(application);
        _testee = Application.FindFormTitle(application,
                       SearchMatchMode.MatchExact, true, 2000);
        Assert.IsTrue(_testee != null);
    }



Step7.Add a tear down member method to close the activated form
        In the previous tutorial, it is not necessary to declare the tear down method,
        because garbage collection is automatically performed. But in this tutorial, a
        tear down method is required to close the application (form) activated by the
        set up method.


7The assertion failed in setup() that will skip the runTest() and then call teardown()
directly.

Windows Programming Tutorial – Ranorex                                                    - 3-
[TearDown]
    public void tearDown() {
        _testee.Close();
    }

Step8.Add a member method to control the mouse 8
        Ranorex offers several ways to find 9 GUI widgets (controls) on the screen and
        also offers the control of mouse and keyboard. Now add a member method as
        below which can move the mouse pointer to the target control and then click
        on it.

    public void moveToControlAndClick(Form form, string text) {
        Assert.IsTrue(form != null);
        Control control = form.FindChildText(text);
        Assert.IsTrue(control != null);
        Mouse.MoveToControl(control);
        Mouse.ClickControl(control);
    }



Step9.Write a test script
        Now we can write test cases by using the above moveToControlAndClick
        method. Add a new member method with the following codes to
        automatically perform the user’s actions 10 : 1+12-3-4*5/6=




8     The same as the setUp() method, if there is any assertion failed in the
moveToControlAndClick() method, the NUnit will skip the remaining codes and then
call tearDown() directly.
9   Ranorex provides several methods: by object name or id, text and class name. For
more information, please refer to the Ranorex document.
10 Design your actions sequence for practice if you have more time after finishing the

tutorial

Windows Programming Tutorial – Ranorex                                            - 4-
public void runScripts() {
      moveToControlAndClick(_testee, "1");
      moveToControlAndClick(_testee, "+");
      moveToControlAndClick(_testee, "1");
      moveToControlAndClick(_testee, "2");
      moveToControlAndClick(_testee, "-");
      moveToControlAndClick(_testee, "3");
      moveToControlAndClick(_testee, "-");
      moveToControlAndClick(_testee, "4");
      moveToControlAndClick(_testee, "*");
      moveToControlAndClick(_testee, "5");
      moveToControlAndClick(_testee, "/");
      moveToControlAndClick(_testee, "6");
      moveToControlAndClick(_testee, "=");
 }



Step10. Add assertion integrated with NUnit Framework
      Now we would like to make sure the result of the previous calculation is 5. Add
      a member method with [Test] attribute (so that it can be identified by UnitRun
      add-in) as follows:

 [Test]
 public void runTest() {
      Assert.IsTrue(_testee != null);
      runScripts();
      Control control = _testee.FindControlName("_resultDisplayer");
      Assert.IsTrue(control != null);
      Assert.AreEqual(control.Text, "5.");
 }



Step11. Run the unit test through UnitRun add-in
      While the unit test is under running, please do not move your mouse or click
      any key. Any event generated by mouse moving or clicking will cause the test
      failed.




Windows Programming Tutorial – Ranorex                                           - 5-
Figure 4 Run unit test through UnitRun add-in.




   Figure 5 NUnit activate simple calculator through Ranorex and assert the value.


                                                                     – End Tutorial –




Windows Programming Tutorial – Ranorex                                           - 6-

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 Exams
 
Unit testing
Unit testing Unit testing
Unit testing
 
Selenium
SeleniumSelenium
Selenium
 
Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best Practices
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Fundamentals of HTML5
Fundamentals of HTML5Fundamentals of HTML5
Fundamentals of HTML5
 
Equivalence partinioning and boundary value analysis
Equivalence partinioning and boundary value analysisEquivalence partinioning and boundary value analysis
Equivalence partinioning and boundary value analysis
 
Selenium
SeleniumSelenium
Selenium
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
Introduction to Web Programming
Introduction to Web ProgrammingIntroduction to Web Programming
Introduction to Web Programming
 
Dotnet Basics Presentation
Dotnet Basics PresentationDotnet Basics Presentation
Dotnet Basics Presentation
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
Bug life cycle
Bug life cycleBug life cycle
Bug life cycle
 
Java Array String
Java Array StringJava Array String
Java Array String
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Silk Performer Presentation v1
Silk Performer Presentation v1Silk Performer Presentation v1
Silk Performer Presentation v1
 
SOFTWARE TESTING
SOFTWARE TESTINGSOFTWARE TESTING
SOFTWARE TESTING
 
Web application testing with Selenium
Web application testing with SeleniumWeb application testing with Selenium
Web application testing with Selenium
 
Money adder
Money adderMoney adder
Money adder
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 

Andere mochten auch

Ranorex Studio - Introduction, Features & Limitations - Mobile Test Automati...
Ranorex Studio - Introduction, Features & Limitations -  Mobile Test Automati...Ranorex Studio - Introduction, Features & Limitations -  Mobile Test Automati...
Ranorex Studio - Introduction, Features & Limitations - Mobile Test Automati...eVideoTuition
 
How To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test AutomationHow To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test AutomationRanorex
 
Why Test Automation Fails
Why Test Automation FailsWhy Test Automation Fails
Why Test Automation FailsRanorex
 
Automated Testing Tools for Desktop, Web and Mobile Software
Automated Testing Tools for Desktop, Web and Mobile SoftwareAutomated Testing Tools for Desktop, Web and Mobile Software
Automated Testing Tools for Desktop, Web and Mobile SoftwareRanorex
 
Automated Desktop and Web Testing Webinars
Automated Desktop and Web Testing WebinarsAutomated Desktop and Web Testing Webinars
Automated Desktop and Web Testing WebinarsRanorex
 
Cross browser testing
Cross browser testingCross browser testing
Cross browser testingSauce Labs
 
SeeTestAutomation - Mobile Test Automation Tool by Experitest
SeeTestAutomation - Mobile Test Automation Tool by ExperitestSeeTestAutomation - Mobile Test Automation Tool by Experitest
SeeTestAutomation - Mobile Test Automation Tool by ExperitestExperitest
 
Top 5 pitfalls of software test automatiion
Top 5 pitfalls of software test automatiionTop 5 pitfalls of software test automatiion
Top 5 pitfalls of software test automatiionekatechserv
 
New trends in testing automation
New trends in testing automationNew trends in testing automation
New trends in testing automationEran Kinsbrunner
 
Organization of Automated Testing
Organization of Automated TestingOrganization of Automated Testing
Organization of Automated TestingKlika Tech, Inc
 
Test automation framework
Test automation frameworkTest automation framework
Test automation frameworkQACampus
 
Winium — это как Selenium, только под Windows
Winium — это как Selenium, только под WindowsWinium — это как Selenium, только под Windows
Winium — это как Selenium, только под WindowsSQALab
 
Role of Automation in Testing
Role of Automation in TestingRole of Automation in Testing
Role of Automation in TestingAnand Bagmar
 
Software Testing Process, Testing Automation and Software Testing Trends
Software Testing Process, Testing Automation and Software Testing TrendsSoftware Testing Process, Testing Automation and Software Testing Trends
Software Testing Process, Testing Automation and Software Testing TrendsKMS Technology
 
Combining Automated Functional And Load Testing
Combining Automated Functional And Load TestingCombining Automated Functional And Load Testing
Combining Automated Functional And Load TestingRanorex
 
Automation testing strategy, approach & planning
Automation testing  strategy, approach & planningAutomation testing  strategy, approach & planning
Automation testing strategy, approach & planningSivaprasanthRentala1975
 

Andere mochten auch (19)

Ranorex Studio - Introduction, Features & Limitations - Mobile Test Automati...
Ranorex Studio - Introduction, Features & Limitations -  Mobile Test Automati...Ranorex Studio - Introduction, Features & Limitations -  Mobile Test Automati...
Ranorex Studio - Introduction, Features & Limitations - Mobile Test Automati...
 
How To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test AutomationHow To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test Automation
 
Why Test Automation Fails
Why Test Automation FailsWhy Test Automation Fails
Why Test Automation Fails
 
Automated Testing Tools for Desktop, Web and Mobile Software
Automated Testing Tools for Desktop, Web and Mobile SoftwareAutomated Testing Tools for Desktop, Web and Mobile Software
Automated Testing Tools for Desktop, Web and Mobile Software
 
Automated Desktop and Web Testing Webinars
Automated Desktop and Web Testing WebinarsAutomated Desktop and Web Testing Webinars
Automated Desktop and Web Testing Webinars
 
Cross browser testing
Cross browser testingCross browser testing
Cross browser testing
 
SeeTestAutomation - Mobile Test Automation Tool by Experitest
SeeTestAutomation - Mobile Test Automation Tool by ExperitestSeeTestAutomation - Mobile Test Automation Tool by Experitest
SeeTestAutomation - Mobile Test Automation Tool by Experitest
 
Automation_testing
Automation_testingAutomation_testing
Automation_testing
 
Top 5 pitfalls of software test automatiion
Top 5 pitfalls of software test automatiionTop 5 pitfalls of software test automatiion
Top 5 pitfalls of software test automatiion
 
New trends in testing automation
New trends in testing automationNew trends in testing automation
New trends in testing automation
 
Organization of Automated Testing
Organization of Automated TestingOrganization of Automated Testing
Organization of Automated Testing
 
Test automation framework
Test automation frameworkTest automation framework
Test automation framework
 
Winium — это как Selenium, только под Windows
Winium — это как Selenium, только под WindowsWinium — это как Selenium, только под Windows
Winium — это как Selenium, только под Windows
 
Role of Automation in Testing
Role of Automation in TestingRole of Automation in Testing
Role of Automation in Testing
 
Software Testing Process, Testing Automation and Software Testing Trends
Software Testing Process, Testing Automation and Software Testing TrendsSoftware Testing Process, Testing Automation and Software Testing Trends
Software Testing Process, Testing Automation and Software Testing Trends
 
Combining Automated Functional And Load Testing
Combining Automated Functional And Load TestingCombining Automated Functional And Load Testing
Combining Automated Functional And Load Testing
 
Test automation process
Test automation processTest automation process
Test automation process
 
Automation testing strategy, approach & planning
Automation testing  strategy, approach & planningAutomation testing  strategy, approach & planning
Automation testing strategy, approach & planning
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 

Ähnlich wie Tutorial ranorex

Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Fwdays
 
Qtp 9.2 examples
Qtp 9.2 examplesQtp 9.2 examples
Qtp 9.2 examplesmedsherb
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinSigma Software
 
J unit presentation
J unit presentationJ unit presentation
J unit presentationPriya Sharma
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 
NicoleMaguire_NEES_FinalReport
NicoleMaguire_NEES_FinalReportNicoleMaguire_NEES_FinalReport
NicoleMaguire_NEES_FinalReportNicole Maguire
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBaskar K
 
Introduction To Programming IP5
Introduction To Programming IP5Introduction To Programming IP5
Introduction To Programming IP5Mark Simon
 
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...Andrey Karpov
 
Qtp 9.2 tutorials
Qtp 9.2 tutorialsQtp 9.2 tutorials
Qtp 9.2 tutorialsmedsherb
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answersRamu Palanki
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answersRamu Palanki
 
QTP with Descriptive programming
QTP with Descriptive programmingQTP with Descriptive programming
QTP with Descriptive programmingKuldeep Sharma
 
Qtp with descriptive programming
Qtp with descriptive programmingQtp with descriptive programming
Qtp with descriptive programmingmedsherb
 

Ähnlich wie Tutorial ranorex (20)

Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"
 
Qtp 9.2 examples
Qtp 9.2 examplesQtp 9.2 examples
Qtp 9.2 examples
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita Galkin
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
NicoleMaguire_NEES_FinalReport
NicoleMaguire_NEES_FinalReportNicoleMaguire_NEES_FinalReport
NicoleMaguire_NEES_FinalReport
 
Junit
JunitJunit
Junit
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NET
 
Introduction To Programming IP5
Introduction To Programming IP5Introduction To Programming IP5
Introduction To Programming IP5
 
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
 
QTP 9.2
QTP 9.2QTP 9.2
QTP 9.2
 
Qtp 9.2 tutorials
Qtp 9.2 tutorialsQtp 9.2 tutorials
Qtp 9.2 tutorials
 
Unit testing in Unity
Unit testing in UnityUnit testing in Unity
Unit testing in Unity
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answers
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answers
 
QTP with Descriptive programming
QTP with Descriptive programmingQTP with Descriptive programming
QTP with Descriptive programming
 
Qtp with descriptive programming
Qtp with descriptive programmingQtp with descriptive programming
Qtp with descriptive programming
 

Mehr von radikalzen

Wangi+kaki+ibu
Wangi+kaki+ibuWangi+kaki+ibu
Wangi+kaki+iburadikalzen
 
Syekh+siti+jenar
Syekh+siti+jenarSyekh+siti+jenar
Syekh+siti+jenarradikalzen
 
Serat+sabdo+jati
Serat+sabdo+jatiSerat+sabdo+jati
Serat+sabdo+jatiradikalzen
 
Perkampungan+hantu+bag+6
Perkampungan+hantu+bag+6Perkampungan+hantu+bag+6
Perkampungan+hantu+bag+6radikalzen
 
Budidaya jamurtiram
Budidaya jamurtiramBudidaya jamurtiram
Budidaya jamurtiramradikalzen
 
Budidaya jamurtiram
Budidaya jamurtiramBudidaya jamurtiram
Budidaya jamurtiramradikalzen
 
Joke+pembohong
Joke+pembohongJoke+pembohong
Joke+pembohongradikalzen
 
Ilmu hitamrawarontek
Ilmu hitamrawarontekIlmu hitamrawarontek
Ilmu hitamrawarontekradikalzen
 
Ilmu+gaib+islam+kejawen
Ilmu+gaib+islam+kejawenIlmu+gaib+islam+kejawen
Ilmu+gaib+islam+kejawenradikalzen
 
Hakekat+dan+sumber+kekuatan+ilmu+gaib
Hakekat+dan+sumber+kekuatan+ilmu+gaibHakekat+dan+sumber+kekuatan+ilmu+gaib
Hakekat+dan+sumber+kekuatan+ilmu+gaibradikalzen
 
Deka deteksidininerakaatausiksa
Deka deteksidininerakaatausiksaDeka deteksidininerakaatausiksa
Deka deteksidininerakaatausiksaradikalzen
 
Cendana+dan+cendini
Cendana+dan+cendiniCendana+dan+cendini
Cendana+dan+cendiniradikalzen
 
Cara+mengatisipasi+sihir
Cara+mengatisipasi+sihirCara+mengatisipasi+sihir
Cara+mengatisipasi+sihirradikalzen
 
Makna+ajaran+dewa+ruci
Makna+ajaran+dewa+ruciMakna+ajaran+dewa+ruci
Makna+ajaran+dewa+ruciradikalzen
 
Kurma+dan+kesehatan
Kurma+dan+kesehatanKurma+dan+kesehatan
Kurma+dan+kesehatanradikalzen
 
Skripsi%20 andi%20jayanti.
Skripsi%20 andi%20jayanti.Skripsi%20 andi%20jayanti.
Skripsi%20 andi%20jayanti.radikalzen
 
06110040 nafi-fadilah-hayati
06110040 nafi-fadilah-hayati06110040 nafi-fadilah-hayati
06110040 nafi-fadilah-hayatiradikalzen
 

Mehr von radikalzen (19)

Wangi+kaki+ibu
Wangi+kaki+ibuWangi+kaki+ibu
Wangi+kaki+ibu
 
Syekh+siti+jenar
Syekh+siti+jenarSyekh+siti+jenar
Syekh+siti+jenar
 
Serat+sabdo+jati
Serat+sabdo+jatiSerat+sabdo+jati
Serat+sabdo+jati
 
Perkampungan+hantu+bag+6
Perkampungan+hantu+bag+6Perkampungan+hantu+bag+6
Perkampungan+hantu+bag+6
 
Budidaya jamurtiram
Budidaya jamurtiramBudidaya jamurtiram
Budidaya jamurtiram
 
Budidaya jamurtiram
Budidaya jamurtiramBudidaya jamurtiram
Budidaya jamurtiram
 
Joke+pembohong
Joke+pembohongJoke+pembohong
Joke+pembohong
 
Ilmu hitamrawarontek
Ilmu hitamrawarontekIlmu hitamrawarontek
Ilmu hitamrawarontek
 
Ilmu+gaib+islam+kejawen
Ilmu+gaib+islam+kejawenIlmu+gaib+islam+kejawen
Ilmu+gaib+islam+kejawen
 
Hakekat+dan+sumber+kekuatan+ilmu+gaib
Hakekat+dan+sumber+kekuatan+ilmu+gaibHakekat+dan+sumber+kekuatan+ilmu+gaib
Hakekat+dan+sumber+kekuatan+ilmu+gaib
 
Deka deteksidininerakaatausiksa
Deka deteksidininerakaatausiksaDeka deteksidininerakaatausiksa
Deka deteksidininerakaatausiksa
 
Cendana+dan+cendini
Cendana+dan+cendiniCendana+dan+cendini
Cendana+dan+cendini
 
Cara+mengatisipasi+sihir
Cara+mengatisipasi+sihirCara+mengatisipasi+sihir
Cara+mengatisipasi+sihir
 
Makna+ajaran+dewa+ruci
Makna+ajaran+dewa+ruciMakna+ajaran+dewa+ruci
Makna+ajaran+dewa+ruci
 
Kurma+dan+kesehatan
Kurma+dan+kesehatanKurma+dan+kesehatan
Kurma+dan+kesehatan
 
Skripsi%20 andi%20jayanti.
Skripsi%20 andi%20jayanti.Skripsi%20 andi%20jayanti.
Skripsi%20 andi%20jayanti.
 
Skripsi 2
Skripsi 2Skripsi 2
Skripsi 2
 
06110040 nafi-fadilah-hayati
06110040 nafi-fadilah-hayati06110040 nafi-fadilah-hayati
06110040 nafi-fadilah-hayati
 
Unixtoolbox
UnixtoolboxUnixtoolbox
Unixtoolbox
 

Tutorial ranorex

  • 1. Ranorex Tutorial Spirit Du March 27th, 2007 Ver. 1.1.4 Contents  About this Document....................................................................................... 1 Ranorex Installation and Setup ...................................................................... 1 Tutorial – Test SimpleCalculator using Ranorex............................................ 2 About this Document NUnit framework is very useful for testing a small piece of program without GUI. But how do we test the correctness of GUI interactions? This document introduces a tool Ranorex, which can “simulate” user interactions and perform assertions. We will integrate this tool with the NUnit framework to test the SimpleCalculator developed in your homework. Ranorex Installation and Setup Ranorex is a Windows GUI test and automation Library for C++, Python, and the .Net languages. The user (e.g. the software tester) should use the functionalities of the programming languages like Python or C# as a base, and enlarge it with the GUI automation functionality of Ranorex. Before starting this tutorial, it needs to get the Ranorex installer form the URL: http://www.ranorex.com/download/ Download the free edition and execute the installer with default settings. After installation 1 , copy the file: RanorexCore.dll 2 from [Ranorex Location] 3 BinNet2.0 and then paste to [Windows] 4 system32 as global library cache 5 . 1 You don’t have to install the Ranorex. But you do need to do this set up step by yourself because there is no such file in system32 folder in the computer lab. 2 Any project developed with Ranorex will run with RanorexCore.dll 3 The default location is C:Program FilesRanorex-1.1.0 4 The default location for Windows XP/2000 is C:WinNT 5 It will facilitate the development without denoting the location of RanorexCore.dll in each project. Windows Programming Tutorial – Ranorex - 1-
  • 2. Tutorial – Test SimpleCalculator using Ranorex Step1.Open the existing Visual Studio Solution which contains your calculator. As shown in Figure 1, SimpleCalculator is the project developed in the previous homework which is contained in Windows Programming solution. Figure 1 The Solution contains SimpleCalculator project Step2.Add a class: GUITester into existing project. Figure 2 Add a new class: GUITester Step3.Add RanorexNet references 6 Figure 3 Add Ranorex reference Step4.Add using declarations Open the GUITester.cs and add the following two declarations. 6 Default location: C:Program FilesRanorex-1.1.0BinNet2.0 Windows Programming Tutorial – Ranorex - 2-
  • 3. using NUnit.Framework; using Ranorex; Step5.Declare a test fixture and a member data This is similar to the previous tutorial; add a test fixture attribute before the class declaration. Then, change the visibility to public and add a new field: _testee. namespace SimpleCalculatorGUITests { [TestFixture] public class GUITester { Form _testee; } } Step6.Use the Ranorex to activate SimpleCalculator in setup method 7 . Add a member method, setup(), into GUITester class. Note that the [SetUp] attribute and the value of application string must be the same as the title (name of the .exe file) of your simple calculator. [SetUp] public void setUp() { // Project Name or executable file name string application = "SimpleCalculator"; Application.SleepTime = 50; Mouse.MoveTime = 10; Application.Start(application); _testee = Application.FindFormTitle(application, SearchMatchMode.MatchExact, true, 2000); Assert.IsTrue(_testee != null); } Step7.Add a tear down member method to close the activated form In the previous tutorial, it is not necessary to declare the tear down method, because garbage collection is automatically performed. But in this tutorial, a tear down method is required to close the application (form) activated by the set up method. 7The assertion failed in setup() that will skip the runTest() and then call teardown() directly. Windows Programming Tutorial – Ranorex - 3-
  • 4. [TearDown] public void tearDown() { _testee.Close(); } Step8.Add a member method to control the mouse 8 Ranorex offers several ways to find 9 GUI widgets (controls) on the screen and also offers the control of mouse and keyboard. Now add a member method as below which can move the mouse pointer to the target control and then click on it. public void moveToControlAndClick(Form form, string text) { Assert.IsTrue(form != null); Control control = form.FindChildText(text); Assert.IsTrue(control != null); Mouse.MoveToControl(control); Mouse.ClickControl(control); } Step9.Write a test script Now we can write test cases by using the above moveToControlAndClick method. Add a new member method with the following codes to automatically perform the user’s actions 10 : 1+12-3-4*5/6= 8 The same as the setUp() method, if there is any assertion failed in the moveToControlAndClick() method, the NUnit will skip the remaining codes and then call tearDown() directly. 9 Ranorex provides several methods: by object name or id, text and class name. For more information, please refer to the Ranorex document. 10 Design your actions sequence for practice if you have more time after finishing the tutorial Windows Programming Tutorial – Ranorex - 4-
  • 5. public void runScripts() { moveToControlAndClick(_testee, "1"); moveToControlAndClick(_testee, "+"); moveToControlAndClick(_testee, "1"); moveToControlAndClick(_testee, "2"); moveToControlAndClick(_testee, "-"); moveToControlAndClick(_testee, "3"); moveToControlAndClick(_testee, "-"); moveToControlAndClick(_testee, "4"); moveToControlAndClick(_testee, "*"); moveToControlAndClick(_testee, "5"); moveToControlAndClick(_testee, "/"); moveToControlAndClick(_testee, "6"); moveToControlAndClick(_testee, "="); } Step10. Add assertion integrated with NUnit Framework Now we would like to make sure the result of the previous calculation is 5. Add a member method with [Test] attribute (so that it can be identified by UnitRun add-in) as follows: [Test] public void runTest() { Assert.IsTrue(_testee != null); runScripts(); Control control = _testee.FindControlName("_resultDisplayer"); Assert.IsTrue(control != null); Assert.AreEqual(control.Text, "5."); } Step11. Run the unit test through UnitRun add-in While the unit test is under running, please do not move your mouse or click any key. Any event generated by mouse moving or clicking will cause the test failed. Windows Programming Tutorial – Ranorex - 5-
  • 6. Figure 4 Run unit test through UnitRun add-in. Figure 5 NUnit activate simple calculator through Ranorex and assert the value. – End Tutorial – Windows Programming Tutorial – Ranorex - 6-