ºÝºÝߣs from my presentation about Dynamics 365 User Automated Tests with Selenium and EasyRepro
More Info: https://github.com/crisfervil/blog/blob/master/source/_drafts/UI-Automated-Tests-in-Dynamics-CRM-365-Part1.md
https://github.com/crisfervil/blog/blob/master/source/_drafts/UI-Automated-Tests-in-Dynamics-CRM-365-Part2.md
26. ?Activity Record Wall
?Business Process Flow
?Charts
?Commandbar
?Dashboards
?Entities (Create,
Update, Delete,
Duplicate Detection,
Assign)
?Global Search
?Guided Help
?Grids
?Sub-Grids
?Navigation
?Notifications
?Performance Center
?Quick Create
?Run Workflows
?Run Reports
Editor's Notes
Introduce myself
Introduce the talk, the topics
What¡¯s UI and browser automated tests?
What¡¯s cross browser testing?
Pros and Cons of automating UI tests
When to automate
Available tools
Introduction to Selenium, architecture description
How to use selenium
Example
Easy Repro Introduction
How to use it, Example
Covered functionality
Limitations of Easy Repro
Desirable features in a test: Login, screenshots, Configuration
How to use it with TFS
What is UI Test Automation?
Any program/script that simulates the User interaction (clicks, keyboard strokes, mouse scroll, touch screen gestures)
What is Browser Automation?
The same applied specifically to a browser
When you test a web page in different combinations of browsers, OS and Devices
Easily repeat steps over and over without getting bored or tired
Humans sometimes skip steps, take shortcuts. Machines don¡¯t
Caveat: Machines would very rarely find usability or unexpected errors.
Speed. Run tests in parallel
Adding a machine (on the cloud) to run your tests is far cheaper than hire someone to run them manually
Write tests is costly.
Every single change in the UI requires update the tests too. Increase the maintenance cost.
Having a architecture or a framework that gets updated independently from your tests reduce costs.
Have you ever seen a Testing Pyramid?
This is not specific to Dynamics.
In any development, we should emphasize the Unit tests, then the Integration tests, and last the UI.
The UI should cover mostly the common happy paths. The weird errors should be tested in the lower levels of the pyramid.
When to Automate?
When the application is mature
When we have enough time
When not to automate?
On Exploration tests
When the UI changes frequently
Tight deadlines
TODO: search more tools
What is Selenium?
Set of tools and libraries to automate and run different browsers
Every modern browser comes with an API that is programmable
Problem is that every API is different
Selenium is the ¡°One ring to rule them all¡± ¡°and in the darkness bind them¡±
WebDriver is one of the components of Selenium
Unifies browsers API elegantly
Well designed
Selenium also provides the same functionality available to different languages/platforms
You can write your tests practically in the same way in c# or Javascript or Ruby
This is another view of Selenium¡¯s Architecture
How do we use selenium with visual studio and c#
First, install the right nuget packages and the appropriate webdrivers
Example of WebDrivers for Chrome and IE
The drivers for Edge are downloaded from a separate page
Overview of the code
This is just a test class, as any unit test, that can be run through the command line or any other running tool.
If any exceptions are thrown, the test will fail.
Can use existing test features like test initializers
After the test, you can Assert to check the results. If not met, than fail.
Analyse code line by line
1 ¨C Create the Driver. There are specific objects for each Browser. We can use an interface instead of this and configure the browser we want to use at runtime.
2 ¨C Equivalent to typing a url in the address bar
3 ¨C Find an element in the page. If is not present, an exception is thrown
4 ¨C Perform an action on the selected element. If the action can¡¯t be performed, an exception is thrown
5 ¨C Find the button
6 ¨C perform an action on the button. Other available actions: Type, click, scroll, swipe, touch actions. Depends on the element type.
Explain waits here. Before execute line 7, Selenium will detect the status of the browser and wait until it becomes completed.
All the reloads, asynchronous requests are completed before moving to the next step.
7 ¨C Find another element
8 ¨C Perform an assert with the content of the element. An element not only let us perform actions on it, it also allow us to get its properties, such as text, location, values, inner elements, etc.
As we¡¯ve seen Selenium is fantastic, but if we want to use it to write tests for Dynamics, it can be quite laborious (require considerable effort)
What are the advantages of Dynamics 365 in terms of UI testing? All the UI elements follow the same pattern and structure.
There¡¯s a perfectly defined naming convention for ui elements.
All you need to know in most cases is the entity name, the attribute names and its data types.
With that ,you could write very generic tests.
EasyRepro is a library meant to facilitate the writing of UI tests for Dynamics 365, leveraging the well defined structure mentioned.
All you need to know is the Entity Name, Attribute name and data type to know how the UI elements are going to be structured and rendered in the form
Easy Repro is an Open Source project
By Microsoft
Built on top of selenium
Still under development, but actively developed.
With some limitations, but with a lot of potential
The same concepts as selenium apply
It all starts installing a Nuget Package
CRM Online Only
Issues with Edge and Firefox
Not Covered
Settings Area
Customization
Advanced Find Query Execution
Export to Excel
Templates
Any Custom Development