Testing CRM with Selenium Ben Walker MA MSc
Testing CRM with Selenium Ben Walker MA, MSc IT Services, University of Oxford 5 th July 2016, UK CRM User Group Presentation
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
Testing CRM with Selenium Agenda • Our use of CRM • Different types of testing • Using Selenium for browser testing • Using Spec. Flow to create test cases
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
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.
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
Testing CRM with Selenium We use CRM For…. • Childcare Waiting List Management System * * Application accessed in part through custom portal
Testing CRM with Selenium We use CRM For…. • Fees, Funding and Scholarship Search * * Application accessed in part through custom portal
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
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
Testing CRM with Selenium We use CRM For…. • Case Management System (our first OOB implementation!) Integration of Share. Point, Outlook and CRM
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?
Testing CRM with Selenium Automated Testing • Traditional Unit Tests • Mocked Unit Tests • Integration Tests using API • Integration Tests using Selenium
Testing CRM with Selenium Automated Testing • Traditional Unit Tests
Testing CRM with Selenium Automated Testing • Traditional Unit Tests
Testing CRM with Selenium Automated Testing • Traditional Unit Tests
Testing CRM with Selenium Automated Testing • Traditional Unit Tests
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)
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!’ • Open. Source Mocking Frameworks for c#: Rhino Mocks, Moq, NMock • Commercial Mocking Frameworks for c#: Just. Mock, Type. Mock
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
Testing CRM with Selenium Automated Testing • Very quick Linq. Pad demo to demonstrate API use http: //www. linqpad. net/
Testing CRM with Selenium Automated Testing
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
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
Testing CRM with 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
Testing CRM with Selenium Web. Driver • Selenium Web. Driver 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 Web. Driver is Chrome, but there also versions for IE, Firefox, Safari, etc. • We can use the Web. Driver to write a framework within which to write Browser based tests for CRM. • http: //www. seleniumhq. org/projects/webdriver/
Testing CRM with Selenium Web. Driver • Webdriver finds elements on the page…
Testing CRM with Selenium Web. Driver • And interacts with them in some way…
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 Site. Map are as expected.
Testing CRM with Selenium Rule #1 Be Patient! • Even when the page declares itself to be fully loaded, it will not be! • js. Execute. Script("return document. ready. State"); 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.
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.
Testing CRM with Selenium Rule #2 – Some fields are not in the DOM unless visible • driver. Find. Element(By. XPath("//span[@class='nav Action. Button. Label' 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.
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
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
Testing CRM with Selenium Demo • Let’s see some of this in action!
Testing CRM with Selenium Driving our tests using Spec. Flow • 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?
Testing CRM with Selenium What is Spec. Flow? • Spec. Flow 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.
Testing CRM with Selenium Why use Spec. Flow? • 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.
Testing CRM with Selenium Why use Spec. Flow? • Spec. Flow ‘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
Testing CRM with Selenium Why use Spec. Flow? A (complex) example
Testing CRM with Selenium Spec. Flow Demo • A quick demo, using our Age Calculator example again
Testing CRM with Selenium Putting it all together • Our Sitemap tests are driven from easily understood Feature files. Easy to maintain and to understand:
Testing CRM with Selenium Useful Resources • http: //www. seleniumhq. org/ • Spec. Flow http: //www. specflow. org • Execute Automation http: //executeautomation. com/blog/ https: //www. youtube. com/channel/UCO 1 auc. BAJg FR 8 odzf. XOZ 5 uw
Testing CRM with Selenium Useful Resources • https: //www. crmug. com/communities/commu nityhome/librarydocuments/viewdocument? Docu ment. Key=05614031 -bcbd-4176 -b 7 ea 46 eba 4 ea 80 d 8 (Unit Testing Plug-ins in Dynamics CRM 2013 by Wael Hamze, Ramon Tebar) • https: //xrmtestframework. codeplex. com/
Testing CRM with Selenium Questions? • ben. walker@it. ox. ac. uk • @bwmodular
- Slides: 45