This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Getting Started

Step by step tutorial to create your first test automtion.

What will be covered ?

  • Add a new application and configure it in pixel-designer

  • Capture the controls for application that needs to be automated in pixel-designer

  • Create a new automation project in pixel-designer

  • Configure how application will be launched and closed as part of environment setup and tear down in pixel-designer

  • Add new test fixtures and test cases in pixel-designer

  • Execute test cases in pixel-designer

  • Publish the project version from pixel-designer

  • *Create a template in pixel-runner

  • *Execute test case in pixel-runner using template

  • *See details of test case execution on web portal

    To follow along with steps marked with *, pixel-designer should be running in online mode

Prerequisites

You should have a working setup as described in Installation section. If you want to quickly try out pixel-designer only, you don’t need to setup pixel-persistence service and can use pixel-designer in offline mode.

1 - Add new application

Add and configure new application for which we need to create automation test cases in pixel-designer

In this tutorial, we will add and configure “calculator” application that come with the windows. Launch the pixel-designer and let’s get started.

  1. Click the Add (+) button in the “Applications Repository” pane at the bottom.
  2. Click “Windows App” from the popup menu.
  3. An application icon appears with name “1”.
  4. Select this application icon, right click -> rename. Rename apaplication to “Calculator” and press enter. The new name should start showing up now as shown below.
  5. Select this application icon again, right click - > Edit.
  6. Application details are in edit mode in property grid pane on right side.
  7. Set the value of “ExecutablePath” to “calc” and click on save icon on top right of property grid pane.

Some tutorials toward the end require that pixel-persistence service is up and running and pixel-designer is running in online mode. You can continue in offline mode for the most part if you want to quickly get a feel of pixel-designer without investing time in all necessary setup.

2 - Capture controls

Capture and configure controls to automate for the calculator application in pixel-designer

In this tutorial, we will capture and configure the controls belonging to calculator application that need to be automated in pixel-designer

  1. Double click the “Calculator” application icon to activate “Control Explorer” inside the Application repoitory.

  2. Launch calculator application by hitting win+r and then type calc followed by enter.

  3. In pixel-designer, click Screen Scrappers -> UIA Scrapper from top level menu. At this point, if you hover over any control on applications that support UIA, they will get highlighted with an orange rectangle as shown below.

  4. Hold left ctrl and click any of the buttons on calculator to capture it. If successfully capture, highlight rectangle will turn green.

  5. Let’s capture button 0, 1, 2, 3, add, subtract, multiply, divide, equals, clear and result.

  6. Once all controls are captured, you can go back to Screen scrappers -> UIA Scrapper and click it again to exit capture mode.

  7. All the captured controls will appear in control explorer view now. You can now rename these controls by selecting them and right click -> rename or you can inspect and modify captured details by right click -> Configure.

  8. Control explorer should look as shown below at this point assuming you have also renamed the controls.

3 - Create new project

Create a new automation project for holding test cases for calculator

In this tutorial, we will create a new automation project. Automation project can contain test fixtures and test cases for our application.

  1. Click on the Add (+) icon left of “Projects” on the Home tab.

  2. This will open the dialog to create new automation project.

  3. Set the name as “Calculator Demo” and click “Create”.

  4. The project will be created and opened now in designer in a new tab.

4 - Setup and Teardown

Having created a new automation project, We will configure how the application to be tested is launched and closed.

In this tutorial, we will configure the automation process so that we can launch Calculator application as part of environment setup and close Calculator application as part of environment teardown.

  1. At this point, “Calculator Demo” should be the active tab in pixel-designer.

  2. Double click on the “Automation Process” component to expand it. Your designer should look shown below :

  3. Navigate to application view by clicking the back button from control explorer view and drag drop the Calculator application on “Application Pool” component. This will add a “Calculator” application component and a “UIA Control Locator” child component of the “Calcultor” component. Select the “UIA Control Locator” component and change “MatchProcessId” property to false.

    There are two window associated with Calculator. The child window has a different process Id.Hence, we need to configure to not match ProcessId while looking for controls.

  4. Drag drop the application on “Environment Setup” and “Environment Teardown” components. However, this time a “Sequence : Calculator” component is added.

    When you drag drop an application on any of the component except “Application Pool”, a new component with name “Sequence:ApplicationName” is created. Application sequence components create a scope for the application. All components inside an application scope act on the target application e.g. launch component will launch application identified by the current application scope.

    Tip : If you are in control explorer view for a given application, you can also drag drop the empty rectangle icon from top left.

  5. Open the script editor for project initialization script by clicking Project -> Edit Script from top level menu. Declare a variable calculatorWindow of type ApplicationWindow as shown and save the script. Also, add required namespace for type ApplicationWindow.

    pixel-designer comes integrated with a C# code editor with rich features like intellisense and code highlighting e.g. if you hover over ApplicationWindow , you will see a yellow light bulb. You can click it and see available options that can help you to automatically add missing namespace without typing it manually.

  6. Add below four components to “Environemtn Setup -> Sequence : Calculator” component from the Components pane on left. You can search for component name to filter.

    • Launch : This is required to launch the application. No configuration required.
    • Delay : This is required to add a delay between execution of next step. Select this component and set the value of “Delay Amount” to 3 in property grid.
    • Find Desktop Window : This is used to find an ApplicationWindow using different criteria e.g. title of window to find. Select this component after adding and set “Match Criteria” to “Equals”, “Window Title” to “Calculator” and “TargetWindow” to “calculatorWindow” variable from dropdown that we declared earlier in property grid.
    • Attach : This is required to attach to an existing application. Select this component and set the value of “Attach mode” to “Attach to Window” and value of “Attach To” to “calculatorWindow” variable from dropdown

    Normally Launch will be the only component required in case of other applications like notepad. However, calc.exe spawns few other processes. Hence, we need to find the Calculator window and attach to it manually. Although, this makes tutorial a bit complicated, it also gives an idea on the flexibility offered by pixel-deigner to handle custom scenarios and a glimpse of scripting capabilities it has to offer.

  7. Add Close component to “Environemtn Teardown -> Sequence : Calculator”. Close component will exit the Calculator application that we attached to earlier during environment setup.

  8. Your screen should look as shown below at this step.

  9. Save the process from File -> Save.

  10. Ensure that Calculator application is not already running.

  11. Activate the “Test Explorer” pane on left and click on the Setup icon button.

  12. Calculator application should be launched now.

  13. Teardown icon button on “Test Explorer” toolbar should be enabled now. Click on it to close the application.

5 - Add fixtures

Add few fixtures to the automation process

In this tutorial, we will add few fixtures to the automation process.

  1. Activate the “Test Explorer” pane.

  2. Click on “Add new fixture” icon button on the toolbar

  3. This will open the new popup dialog to add new test fixture.

  4. Leave the default values and click on save button to create fixture.

  5. Repeat the process twice to create two more fixture with default value.

  6. At this step, you should have three fixtures and your screen should look as shown below.

6 - Add test cases

Add few test cases to the automation process

In this tutorial, we will add a test case to each fixture we created earlier.

Creating new test cases

  1. Activate the “Test Explorer” pane.

  2. Right click “Fixture#1” and select “Add Test”.

  3. This will open popup window to add a new test case.

  4. Change the name to “Add Numbers” and click save.

  5. Similarly, add a new test case named “Multiply Numbers” to Fixture#2 and “Simulate Error” to Fixture#3.

  6. Activate the “Test Data Repository” pane at the bottom and drag drop “EmptyDataSource” on each test case.

    Test cases require that a data source should be assigned to them before they become active and can be worked with. Your test case will execute once for each data record returned by the data source. Test data source can be coded or mapped to csv files. EmptyDataSource returns only one data record and can be used with any test case that doesn’t depend on any data. It is created by default for each new automation project. It is also posssible to override the data source at runtime using prefixes to run your test cases with different sets of data dynamically.

  7. After above steps, your screen should look as shown below.

Configure steps for test case “Fixture#1 -> Add Numbers”

  1. Right click test case “Add Numbers” and click open.

  2. Test case “Add Numbers” should be open on designer canvas now.

  3. Drag drop the calculator application from application explorer on to “Add Numbers” component.

  4. Drag drop controls 1, add, 2 and equals from Control explorer to the “Sequence : Calculator” component added in previous step.

  5. After above steps, your screen should look as shown below.

  6. Drag drop component “UIA -> Invoke” from component pane to controls 1, 2, add and equals.

  7. Right click “Add Numbers” test case in test explorer and click “Save” or click save all icon on test explorer toolbar.

  8. Ensure Calculator application is not alredy running.

  9. Setup environment from the test explorer.

  10. Select the test case “Add Numbers” and then click “Run Selected” button from the test explorer toolbar to execute the test case.

  11. Tear down environment to close the calculator application.

Configure steps for test case “Fixture#2 -> Multiply Numbers”

  1. Right click test case “Multiply Numbers” and click open.

  2. Test case “Multiply Numbers” should be open on designer canvas now.

  3. Drag drop the calculator application from application explorer on to “Setup” component

  4. Drag drop control clear from control explorer to the to the “Sequence : Calculator” component added in previous step and add “UIA -> Invoke” component to clear control component. This is required to clear the results from previous test case before executing the test case.

  5. Drag drop the calculator application from application explorer on to “Multiply Numbers” component

  6. Drag drop controls 1, multiply, 2 and equals from Control explorer to the “Sequence : Calculator” component added in previous step .

  7. Instead of “UIA -> Invoke” component which automates the control using API, we will simulate mouse click using “Input Device -> Mouse -> Click” component. Add “Input Device -> Mouse -> Click” component to all the controls.

    Simulation using mouse and keyboard requiress application to have focus. We can ensure that by setting “Requires Focus” property to true on the application sequence component added to test case.

  8. Right click “Multiply Numbers” test case in test explorer and click “Save” or click save all icon on test explorer toolbar.

  9. After above steps, your screen should look as shown below.

  10. Ensure Calculator application is not alredy running.

  11. Setup environment from the test explorer.

  12. Select the test case “Multiply Numbers” and then click “Run Selected” button from the test explorer toolbar to execute the test case.

  13. Tear down environment to close the calculator application.

Configure steps for test case “Fixture#3 -> Simulate error”

  1. Right click test case “Simulate error” and click open.

  2. Drag drop the calculator application from application explorer on to “Simulate Error” component.

  3. Add “Scripting -> Script [Inline]” component to the application sequence.

  4. Set the content as shown below

  5. Right click “Simulate error” test case in test explorer and click “Save” or click save all icon on test explorer toolbar.

  6. Ensure Calculator application is not alredy running.

  7. Setup environment from the test explorer.

  8. Select the test case “Simulate error” and then click “Run Selected” button from the test explorer toolbar to execute the test case.

  9. Execution of test case will fail.

  10. Tear down environment to close the calculator application.

Run all the test cases simultaneously

  1. Ensure Calculator application is not alredy running.
  2. Setup environment from the test explorer.
  3. Click “Run All” from the test explorer.
  4. Tear down environment once all test cases are executed.

7 - Publish project

Publish a given version of project.

In this tutorial, we will look at how can we publish a specific version of project.

Let’s assume you have a software with current version 8.x in production and next upcoming version is 9.x. As the development team is working on 9.x feature, QA team will be adding automation test cases simultaneously. Eventually, 9.x version will be frozen and work will start on next version 10.x. The QA team maintaining the automation project in pixel-designer has active version 1.x ( for 9.x of software under test). The QA team can now publish version 1.x when they think they are done with all the automation test cases for version 9.x of software. Publishing 1.x will create a cloned version 2.x. 1.x can’t be opened anymore in pixel-designer. The QA team now starts working with version 2.x of automation project to add new automation test cases for changes coming in version 10.0 of software.

  1. Close the automation project by clicking x on the “Calculator Demo” tab.

  2. Home tab should be active now.

  3. Hover over the project name to show hidden icons and click on the settings button next to the project name to open the version manager screen.

  4. Click publish next to version 1.0.0.0 to publish this version and create a new incremented version 2.0.0.0. Version 2.0.0.0 will start as an exact clone of 1.0.0.0.

  5. You can close the version manager screen now and can open the new version 2.0.0.0 to edit.

8 - Execute test cases

Create templates in pixel-runner and use them to execute your test cases.

This tutorial requires that all the previous steps in pixel-designer were done in online mode.

In this tutorial, we will create templates in pixel-runner and use these templates to execute test cases in pixel-runner. Templates capture the details of which test cases should be executed for a given version of automation project.

Creating templates in pixel-runner

  1. Launch command prompt and change directory to where pixel-run.exe is located. See setup guide for pixel-runner if required.

  2. Run pixel-run template --help to see help for templates

  3. Run pixel-run template new to create a new template and follow instructions to provide required value. This template will execute all test cases

  4. Repeat step 3 to create another template as shown below. This template will execute only test cases belonging to Fixture#1 for project “Calculator Demo”

Test selectors are C# scripts which can be used to filter if a test case belonging to a given fixture can be executed.

Executing test cases in pixel-runner using templates

  1. Run pixel-run run template calculator-all 1.0.0.0 to run template calculator-all for version 1.0.0.0 of automation project.

  2. Run pixel-run run template calculator-f1 2.0.0.0 to run template calculator-f1 for version 2.0.0.0 of automation project.

9 - View Test Results

View test results on the dashboard.

In this tutorial, we will see how to view the reports for test case execution on the web dashboard.

  1. Navigate to (https://localhost:5001/persistence)[https://localhost:5001/persistence] on your browser of choice.

    Depending on your deployment of pixel-persistence service, base url can be different.

  2. Click on sessions tab to see all the sessions you have executed from pixel-runner

  3. Click “Show Details” on any session to see the details for that session.

  4. Click “View Stats” for any of the test case to see details for that test case.