Presentation is loading. Please wait.

Presentation is loading. Please wait.

Testing CRM with Selenium Ben Walker MA, MSc IT Services, University of Oxford 5 th July 2016, UK CRM User Group Presentation.

Similar presentations


Presentation on theme: "Testing CRM with Selenium Ben Walker MA, MSc IT Services, University of Oxford 5 th July 2016, UK CRM User Group Presentation."— Presentation transcript:

1 Testing CRM with Selenium Ben Walker MA, MSc IT Services, University of Oxford 5 th July 2016, UK CRM User Group Presentation

2 Testing CRM with Selenium About me Technical Team Lead 20 years in IT, working with CRM since 2011 ben.walker@it.ox.ac.uk @bwmodular

3 Testing CRM with Selenium Agenda Our use of CRM Different types of testing Using Selenium for browser testing Using SpecFlow to create test cases

4 Testing CRM with Selenium The University of Oxford 22,000 Students 12,000 Staff 38 Colleges 140 Academic Departments 6 Museums 11 million books on 120 miles of shelving in the Bodleian library alone

5 Testing CRM with Selenium Using CRM at the University We’ve been using Dynamics CRM since around 5 years. Our focus has mostly been bespoke ‘XRM’ applications. User base of around 1500 users, although many of these are using custom portals rather than using CRM directly. Using CRM 2015 on premise.

6 Testing CRM with Selenium We use CRM For…. Childcare Waiting List Management System * Fees, Funding and Scholarship Search * Internal Research Application Management System * US Loans Management System Media Database Publications Subscription Management System * Undergraduate Admissions Decision System * Case Management System ( our first OOB implementation! ) * Application accessed in part through custom portal

7 Testing CRM with Selenium We use CRM For…. Childcare Waiting List Management System * * Application accessed in part through custom portal

8 Testing CRM with Selenium We use CRM For…. Fees, Funding and Scholarship Search * * Application accessed in part through custom portal

9 Testing CRM with Selenium We use CRM For…. Internal Research Application Management System * US Loans Management System Media Database Publications Subscription Management System * * Application accessed in part through custom portal

10 Testing CRM with Selenium We use CRM For…. Undergraduate Admissions Decision System * Helps 1,400 staff in their decision making processes 18,000 applications have to be assessed in a very short period of time Helps with Widening Participation programme and allocation of candidates across colleges, ensuring the best chance of interview * Application accessed in part through custom portal I’m not the only one who leaves things until the day before

11 Testing CRM with Selenium We use CRM For…. Case Management System (our first OOB implementation!) Integration of SharePoint, Outlook and CRM

12 Testing CRM with Selenium Complex Security Mixture of Security Role and BU/Team based security 25 different security roles 100 + teams How do we make sure that security is maintained?

13 Testing CRM with Selenium Automated Testing Traditional Unit Tests Mocked Unit Tests Integration Tests using API Integration Tests using Selenium

14 Testing CRM with Selenium Automated Testing Traditional Unit Tests

15 Testing CRM with Selenium Automated Testing Traditional Unit Tests

16 Testing CRM with Selenium Automated Testing Traditional Unit Tests

17 Testing CRM with Selenium Automated Testing Traditional Unit Tests

18 Testing CRM with Selenium Automated Testing What about plugins? What about service calls (Query, Create, Update, Delete) or Tracing? ‘Mocked’ Plugin Tests See Unit Testing Plug-ins in Dynamics CRM 2013 by Wael Hamze, Ramon Tebar (Link at end)

19 Testing CRM with Selenium Mocking Mocking Frameworks work by creating an implementation of interfaces. You can then specify the behaviour of the mocked interface and you can assert against properties and methods of the mocked interface. In other words, they say ‘You need an instance of such and such an interface? I’ll give you one, but you have to tell me what should happen when the methods get called!’ OpenSource Mocking Frameworks for c#: Rhino Mocks, Moq, NMock Commercial Mocking Frameworks for c#: JustMock, TypeMock

20 Testing CRM with Selenium Automated Testing Integration tests using API Sometimes you just have to connect to a real CRM instance to test your changes – eg changes to security roles. This cannot be tested in isolation from your CRM instance. But even this doesn’t need to be done in the browser

21 Testing CRM with Selenium Automated Testing Very quick LinqPad demo to demonstrate API use http://www.linqpad.net/

22 Testing CRM with Selenium Automated Testing

23 Testing CRM with Selenium Testing with Selenium Some aspects of CRM cannot be tested using conventional automated unit testing. For example, changes to the Site Map and changes to Security Roles which affect the site map cannot be tested through conventional testing. We have N security roles – not practical to retest each role after each change

24 Testing CRM with Selenium What is Selenium? An automated browser testing tool – two main components Selenium IDE – Record and Playback browser actions Selenium Webdriver – programmatic automation of browsers for many different technologies, including C#, Java, Perl, PHP, Python, Ruby

25 Testing CRM with Selenium Selenium IDE Demo Project Page http://www.seleniumhq.org/download/#selenium_ide Download Page https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/ Selenium IDE is a Firefox plugin

26 Testing CRM with Selenium Selenium WebDriver Selenium WebDriver allows you to write code in various languages which will interact with the web browser in much the same way that the Selenium IDE is able to. Default WebDriver is Chrome, but there are also versions for IE, Firefox, Safari, etc. We can use the WebDriver to write a framework within which to write Browser based tests for CRM. http://www.seleniumhq.org/projects/webdriver/

27 Testing CRM with Selenium Selenium WebDriver Webdriver finds elements on the page…

28 Testing CRM with Selenium Selenium WebDriver And interacts with them in some way…

29 Testing CRM with Selenium The Solution – Selenium & CRM Create library of common browser commands (Log In, Log Out, Click Menu Item, Add new Record, etc) Library of common user/team commands (Switch Roles, Teams, Business Units) Our initial aim was to be able to validate all items on SiteMap are as expected.

30 Testing CRM with Selenium Rule #1 Be Patient! Even when the page declares itself to be fully loaded, it will not be! js.ExecuteScript("return document.readyState"); returns “complete” but page not loaded! Use explicit waits to make sure page is ready. Browser testing is NOT unit testing – reliability is more important than speed.

31 Testing CRM with Selenium Rule #2 – Some fields are not in the DOM unless visible In traditional web browser testing, you might be able to examine the DOM to look at the structure of the page. In Dynamics CRM, you simply cannot do this. The menu only appears in the DOM when you interact with it.

32 Testing CRM with Selenium Rule #2 – Some fields are not in the DOM unless visible driver.FindElement(By.XPath("//span[@class='nav ActionButtonLabel' and text()='"CS"']")).Click(); This command should open the Case Management menu, but the driver will not be able to locate this element unless the sitemap menu itself is being displayed.

33 Testing CRM with Selenium Rule #3 – Some fields are not complete unless visible When a list of menu tiles goes off the visible page, they do not get all of their properties until they are made visible This means we need to be able to scroll through menus programmatically

34 Testing CRM with Selenium Rule #4 – Javascript API still works Any API call which you can call from a web resource can also be called from within your test. Sometimes this is easier than trying to work out how to do things using Selenium

35 Testing CRM with Selenium Demo Let’s see some of this in action!

36 Testing CRM with Selenium Driving our tests using SpecFlow Having a framework is a good starting point…. …but now we have an awful lot of tests to write… How can we make this process easier?

37 Testing CRM with Selenium What is SpecFlow? SpecFlow is a ‘Behaviour Driven Development’ (BDD) tool for.Net. It allows for the creation of Unit Tests in ‘natural’ language. Test scenarios can be written and/or validated by end users, and can easily be added to without having to write any code or understand how Unit Tests work.

38 Testing CRM with Selenium Why use SpecFlow? Non-technical end users can specify testing scenarios. Non-technical end users can be given test scenarios to validate, or can be given a template from which to create testing scenarios which they can understand. Unit tests become a sort of documentation for the functionality which is being tested.

39 Testing CRM with Selenium Why use SpecFlow? SpecFlow ‘features’ are much easier to understand to a developer coming new to a project than Unit Tests. Complex Testing scenarios can be created much more easily and comprehensibly than using traditional Unit Test. As Unit Tests are parameterised, for many scenarios, you end up writing a single Unit test, and passing parameters in from the Feature file – much easier than maintaining lots of individual Unit

40 Testing CRM with Selenium Why use SpecFlow? A (complex) example

41 Testing CRM with Selenium SpecFlow Demo A quick demo, using our Age Calculator example again

42 Testing CRM with Selenium Putting it all together Our Sitemap tests are driven from easily understood Feature files. Easy to maintain and to understand:

43 Testing CRM with Selenium Useful Resources http://www.seleniumhq.org/ SpecFlow http://www.specflow.orghttp://www.specflow.org Execute Automation http://executeautomation.com/blog/ https://www.youtube.com/channel/UCO1aucBAJg FR8odzfXOZ5uw http://executeautomation.com/blog/ https://www.youtube.com/channel/UCO1aucBAJg FR8odzfXOZ5uw

44 Testing CRM with Selenium Useful Resources https://www.crmug.com/communities/commu nity- home/librarydocuments/viewdocument?Docu mentKey=05614031-bcbd-4176-b7ea- 46eba4ea80d8 ( Unit Testing Plug-ins in Dynamics CRM 2013 by Wael Hamze, Ramon Tebar)https://www.crmug.com/communities/commu nity- home/librarydocuments/viewdocument?Docu mentKey=05614031-bcbd-4176-b7ea- 46eba4ea80d8 https://xrmtestframework.codeplex.com/

45 Testing CRM with Selenium Questions? ben.walker@it.ox.ac.uk @bwmodular


Download ppt "Testing CRM with Selenium Ben Walker MA, MSc IT Services, University of Oxford 5 th July 2016, UK CRM User Group Presentation."

Similar presentations


Ads by Google