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.
- Click the Add (+) button in the “Applications Repository” pane at the bottom.
- Click “Windows App” from the popup menu.
- An application icon appears with name “1”.
- 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.
- Select this application icon again, right click - > Edit.
- Application details are in edit mode in property grid pane on right side.
- 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
Double click the “Calculator” application icon to activate “Control Explorer” inside the Application repoitory.
Launch calculator application by hitting win+r and then type calc followed by enter.
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.
Hold left ctrl and click any of the buttons on calculator to capture it. If successfully capture, highlight rectangle will turn green.
Let’s capture button 0, 1, 2, 3, add, subtract, multiply, divide, equals, clear and result.
Once all controls are captured, you can go back to Screen scrappers -> UIA Scrapper and click it again to exit capture mode.
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.
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.
Click on the Add (+) icon left of “Projects” on the Home tab.
This will open the dialog to create new automation project.
Set the name as “Calculator Demo” and click “Create”.
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.
At this point, “Calculator Demo” should be the active tab in pixel-designer.
Double click on the “Automation Process” component to expand it. Your designer should look shown below :
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.
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.
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.
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.
Add Close component to “Environemtn Teardown -> Sequence : Calculator”. Close component will exit the Calculator application that we attached to earlier during environment setup.
Your screen should look as shown below at this step.
Save the process from File -> Save.
Ensure that Calculator application is not already running.
Activate the “Test Explorer” pane on left and click on the Setup icon button.
Calculator application should be launched now.
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.
Activate the “Test Explorer” pane.
Click on “Add new fixture” icon button on the toolbar
This will open the new popup dialog to add new test fixture.
Leave the default values and click on save button to create fixture.
Repeat the process twice to create two more fixture with default value.
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
Activate the “Test Explorer” pane.
Right click “Fixture#1” and select “Add Test”.
This will open popup window to add a new test case.
Change the name to “Add Numbers” and click save.
Similarly, add a new test case named “Multiply Numbers” to Fixture#2 and “Simulate Error” to Fixture#3.
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.
After above steps, your screen should look as shown below.
Right click test case “Add Numbers” and click open.
Test case “Add Numbers” should be open on designer canvas now.
Drag drop the calculator application from application explorer on to “Add Numbers” component.
Drag drop controls 1, add, 2 and equals from Control explorer to the “Sequence : Calculator” component added in previous step.
After above steps, your screen should look as shown below.
Drag drop component “UIA -> Invoke” from component pane to controls 1, 2, add and equals.
Right click “Add Numbers” test case in test explorer and click “Save” or click save all icon on test explorer toolbar.
Ensure Calculator application is not alredy running.
Setup environment from the test explorer.
Select the test case “Add Numbers” and then click “Run Selected” button from the test explorer toolbar to execute the test case.
Tear down environment to close the calculator application.
Right click test case “Multiply Numbers” and click open.
Test case “Multiply Numbers” should be open on designer canvas now.
Drag drop the calculator application from application explorer on to “Setup” component
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.
Drag drop the calculator application from application explorer on to “Multiply Numbers” component
Drag drop controls 1, multiply, 2 and equals from Control explorer to the “Sequence : Calculator” component added in previous step .
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.
Right click “Multiply Numbers” test case in test explorer and click “Save” or click save all icon on test explorer toolbar.
After above steps, your screen should look as shown below.
Ensure Calculator application is not alredy running.
Setup environment from the test explorer.
Select the test case “Multiply Numbers” and then click “Run Selected” button from the test explorer toolbar to execute the test case.
Tear down environment to close the calculator application.
Right click test case “Simulate error” and click open.
Drag drop the calculator application from application explorer on to “Simulate Error” component.
Add “Scripting -> Script [Inline]” component to the application sequence.
Set the content as shown below
Right click “Simulate error” test case in test explorer and click “Save” or click save all icon on test explorer toolbar.
Ensure Calculator application is not alredy running.
Setup environment from the test explorer.
Select the test case “Simulate error” and then click “Run Selected” button from the test explorer toolbar to execute the test case.
Execution of test case will fail.
Tear down environment to close the calculator application.
Run all the test cases simultaneously
- Ensure Calculator application is not alredy running.
- Setup environment from the test explorer.
- Click “Run All” from the test explorer.
- 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.
Close the automation project by clicking x on the “Calculator Demo” tab.
Home tab should be active now.
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.
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.
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
Launch command prompt and change directory to where pixel-run.exe is located. See setup guide for pixel-runner if required.
Run pixel-run template --help
to see help for templates
Run pixel-run template new
to create a new template and follow instructions to provide required value. This template will execute all test cases
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
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.
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.
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.
Click on sessions tab to see all the sessions you have executed from pixel-runner
Click “Show Details” on any session to see the details for that session.
Click “View Stats” for any of the test case to see details for that test case.