Experience Sitecore ! | All posts by martin

Experience Sitecore !

More than 200 articles about the best DXP by Martin Miles

All Sitecore reference - mass links update

All Sitecore References project has just got a mass links update, which includes:

  • All StackOverflow questions to date
  • Blog posts I am watching
  • Reconsideration of existing links in order to achieve precise matching


And just to remind - if you have a blog and want add links from it into All Sitecore References, please use Suggest Links page to do that.


Hope you find this project helpful!



I join "The Monads" team at Sitecore Hackathon 2016! Which team do you?

I am happy to join The Monads team at this highly expected event for all of Sitecore Community on Friday January 29th, will be working together with Richard Seal and Justin L, both from USA. This is my first hackathon ever, so I am excited about the event but at the same time a bit worrying. In any case, will do the most of what I can within these 24 hours.

Are you a Sitecore developer? Why not to join the event, it will cost you nothing (except the tome, for sure) but you can get many valuable insights, meet other Sitecore enthusiasts and result having your own module at the marketplace.

You don't need to find people to create a team - just ask for joining any of existing with two people already, like I did.

To go ahead the hackathon please contact Akshay Sura - he is an organizer and will help you with that.

Best luck to all the teams and have fun!

Onero is now updated to version 1.2

Just have released a new version of Onero. So, what's new?

  • Re-worked UI - removed buttons from main screen in favour of main menu
  • Introduced Testing (settings) profiles - now settings, rules, forms etc. are individual for a profile
  • Created a base for future multiple browser supports (not only FF like now), currently on testing
  • Multiple bug fixes and minor improvements
Please update by the link: http://onero.martinmiles.net/files/Onero 1.2.zip

Looking forward to hear your feedbacks!
Cheers!

Using Onero with non-Sitecore websites - testing Transport for London website

Introduction

In this blog post I am going to demonstrate how you can test any custom website with Onero Page Runner. For our experiment I've decided to pick up Transport for London website located at https://tfl.gov.uk

  1. Creating a profile for a new website
  2. Populating Pages to process from a XML sitemap file
  3. Configuring Rules
  4. Configuring Forms
  5. Running and getting the results

1. Creating a profile for a new website

Onero configuration is based on testing profile. Using profiles it now becomes possible to create a combination of settings, rules and forms unique for for each individual profile and immediately switch between them just by selecting a profiles from a drop-down on a Settings dialog. Usually you would create a profile for one (or few) websites you would like to test with these settings. For our test we'll create a profile called Transport for London. 

Once created, the new profile immediately becomes active. You may change active profile by selecting a profile name from a drop-down as on a image below:

In fact, a profile is a folder with a profile name located on a drive, with its own combination of settings, rules and forms for submission. Changing active profile simply re-points Onero to use a folder with other settings.


2. Populating Pages to process from a XML sitemap file

On the next step we are going to load the list of pages to be tested. It can be also manually pasted into Page to process textbox, but we prefer to load links automatically from a XML sitemap file. Usually it is called sitemap.xml and is placed at the root of website. TFL website has such a file, and as soon as you specify address of that file into Load from xml sitemap textbox and hit Load Links button, Onero will process request and extract list of all the rages out of it. Sitemap file https://tfl.gov.uk/sitemap.xml references 1,374 pages and all they pre-populate the list, as per screenshot below. Also, as you may see, current profile name is displayed at реу window header.

If you hit Start button Onero will process loading all those pages, measure load timings and generate screenshots of every single page (if checked in configuration for current profile).


3. Configuring Rules

Despite is was already possible to run all the pages at the previous step, we now are going to add additional checks to ensure page is correct apart from it just loads correctly. This can be achieved through adding custom verification rules applicable to a specific (or all) pages. Clicking Rules button on the main window brings you the following dialog with all rules (for the current profile) listed.

Check-box on a screenshot below indicates whether a rule is enabled - only enabled rules are executed. [ALL] / [Incl] indicate a scope of rule execution - this is explained below.


This screenshot shows three rules and all they are enabled. The first one has [ALL] execution scope and thus will be executed on every single page; [Incl] for the second and third means that there are certain conditions that specify where exactly these rules are to be executed. Let's now create and configure these rules.

Rule in fact is a JavaScript code that returns a boolean or integer value. Rules is successful when condition clause returns boolean true or integer more than zero. For example you may return amount of elements satisfying some selector, so if more than one found - rule becomes successful. 
For websites that are run with jQuery you may benefit from writing conditions with its powerful selectors, as shown on screenshots below.

First two rules just return is amounts of element found are more than zero. The last rule return more complex combined condition, that checks if an element with specific id presents on a page and then compares the content of that element with expected message.

Please pay attention to Execution scope dropdown box - the one specifies where the rule will be executes. Three options are:
  • Everywhere - runs on every single page
  • Include - runs only on the pages from URL patterns field below
  • Exclude - runs on all the pages except those satisfying URL patterns field below
URL patterns to match store one oк multiple (comma separated) URL substrings to match. If URL has at least one of these patterns as a substring, Onero will run the rule for that page then. 

Please pay attention to a trailing '$'-dollar sign at the en of second and third patters; '$' means end of string. Thus a pattern https://tfl.gov.uk$ will match only landing page with this URL but does not match https://tfl.gov.uk/about. However, if you remove this trailing dollar sign - it will match all the pages on that domain name (because they all contain that URL pattern as a substring).
You can also delete any existing rules from that screen.


4. Configuring Forms

Similar to the rules, forms have their Forms List window, called by clicking Forms button at the main screen. It looks and functions exactly in the same manner. Double-clicking the form name opens it for edit.

Saying "forms" in his context means ability of Onero to find and populate on specific pages, submit them and analyze the results - whether form submission was successful. The last means that if form submission resulted with a confirmation message on a page - Onero is able to address that message and also check if its content matches expected. Alternatively, if form on a page redirects to a confirmation page, Onero can verify that as well and compare with expected redirect URL pattern.

Forms Editor has three logical sections: General (where to submit), Fields (what to submit) and Result match (how to verify).

URL Pattern works same as in rues - matching substring in URL will enable Onero to find and submit a form on that page.
Fields section set fields to find and populate. Field selectors have same syntax as CSS oк jQuery selectors - if it starts with # then it is ID of element, . specified class name, and omitting starting character will prompt Onero that it's an element tag name. In the last case Onero will ask you to confirm that behavior is desired, as it is less frequently used and very likely to be a mistakenly forgotten '#'or '.'


5. Running and getting the results

Onero updates the links with green / red color depending on results, as it processes them. There is also a progress-bar at the right bottom showing overall progress. 

Double clicking green or red link opens Page results for that specific URL, showing also which rules and forms have been executed on that page and their result codes. This is quite handy for cases when you see a URL turning red and would want to find out why exactly it becomes failed. The screenshots below show Page results for first three pages. You would probably notice different rules executed of each of them - that happens because of conditional URL pattern set previously at step (3).


Previewing results immediately is not the only way of inspecting results. At the end of testing process Onero generated report file with all the statistics for that test run. You may find that in reports.csv file located at Results folder within a folder with current settings profile name (Transport for London in our case). The quickest way to access this folder is to click Settings button from main screen and then Open folder button - it will open resulting folder in a separate Explorer window.

Results.csv spreadsheet contains detailed information about what pages have run and how quickly, what rules and form have been executed and their status codes. If Verbose setting is checked - all the results will be displayed (as on a screenshot below), otherwise only failed will be mentioned in that spreadsheet (that is handy as it prevents from informational noise especially on websites with thousands links and dozens of rules.


First column shows pages being executed, the second - rules and forms run on that specific pages with corresponding statuses at third column. Addons statuses column shows overall status for rules and forms executed and Page Status column shows the statuses for the page itself. They may not match, for example the page has loaded correctly and has Successful Page status, while one of its rules broke resulting Addons status to fail. Time to load shows time in milliseconds taken for page to load, rules and form are not mentioned in that figure.

I hope that quick guide managed to explain some basics of working with Onero and looking forward to your feedback!

How to use Onero with Sitecore

As mentioned earlier, Onero interacts with Sitecore via Sitecore Item Web API (I also plan to ensure the data from Sitecore Entity Service in future) and this guidance will guide through this procedure step by step. In general, there are 4 major steps:

  1. Enable Item's WebAPI
  2. Creating pages in Sitecore and forms
  3. Configuring Onero
  4. Running and getting the results


1 .Enable Item's WebAPI

Sitecore Web API requires to be explicitly enabled on your Sitecore instance. If you haven't done this yet, enable it at Sitecore.ItemWebApi.config file. You will end up having something similar to below:


        StandardSecurity
        Read
        false

In order to test if Web API works - just paste http://your.host.name/-/item/v1/ into browser and you will get a response:

{"statusCode":401,"error":{"message":"Access to site is not granted."}}

No worries about error message - it is just telling that no anonymous access allowed to you Web API endpoint, which itself is working well and just served this request. Simply changing itemwebapi.allowanonymousaccess to true will return you valid response with data.

Once you paste this list link into Onero and hit Load Links button - you have everything ready o start the test.

When you click Load Links button, Onero calls Item Web API in Sitecore instance and populates Pages to process box with preview links out of the response. At the moment only items in preview mode are available.

More information about item Web API can be found in the official documentation.


2. Creating pages in Sitecore and forms

Now let's go into Sitecore Content Editor and prepare for more complex testing. I have got a clean Sitecore 8.1 just installed instance here. I use Experience Editor to create 2 web forms on Home page (of course, WFFM for Sitecore 8 should be installed as well)

To make things even simpler, let's take two pre-existing forms coming with WFFM package and set first form to display Success Message while the second to redirect to Success Page. Also create a confirmation page located at /Home/thanks to be referenced by Success Page mode and do not forget to publish website to bring these forms and pages into web database. If everything was done correct at this step, page will look something similar to below:



3. Configuring Onero

Now we want to test forms submission to ensure they function correctly. In Onero hit Forms button, then Add New. It will open Forms Editor where you need to set fields and values to submit the form with, also find and assign submit button and finally specify the results so that Onero can verify whether the page has been submitted correctly.


Also do not forget to check. If you want to delete or modify a form - double click its name.

.


4. Running Onero and getting results
While Onero runs, it changes links in the Page to process box to green or red depending on result status:

Clicking each or already processed URL opens Page results dialog, where all the rules and forms being executed on that specific page are listed:

Double clicking a rule or form opens its editor so it is quite convenient to preview and analyze what went wrong:


At the end of testing process Onero generated report file with all the statistics for that test run. You may find that in reports.csv file located at Results folder within a folder with current settings profile name (Transport for London in our case). The quickest way to access this folder is to click Settings button from main screen and then Open folder button - it will open resulting folder in a separate Explorer window,

Results.csv spreadsheet contains detailed information about what pages have run and how quickly, what rules and form have been executed and their status codes. If Verbose setting is checked - all the results will be displayed (as on a screenshot below), otherwise only failed will be mentioned in that spreadsheet (that is handy as it prevents from informational noise especially on websites with thousands links and dozens of rules.
First column shows pages being executed, the second - rules and forms run on that specific pages with corresponding statuses at third column. Addons statuses column shows overall status for rules and forms executed and Page Status column shows the statuses for the page itself. They may not match, for example the page has loaded correctly and has Successful Page status, while one of its rules broke resulting Addons status to fail. Time to load shows time in milliseconds taken for page to load, rules and form are not mentioned in that figure.


Hope this guide was helpful enough!

Welcome Onero Page Runner - now with Sitecore support!

I have not been posting for a while but there is an easy explanation - I was busy creating Onero Page Runner, which I have finally released. Now it is able to work with Sitecore Item Web API and also became open source project on GitHub.


What is Onero and what is it best for?

Onero is the lightweight testing solution. Is ideally fits for testing websites, especially frequently updated. It is very quick and easy to start, it does not require setting up and configuring complex Selenium frameworks and is best suitable for non-developer IT professionals, like managers, testers, content authors. However developers will also benefit from its simplicity and effectiveness.

Onero doesn't just simply load pages, but also executes simple JavaScript rules against them to verify compliance. As well as Rules it can also submit forms on pages (including authorization login forms to enter protected website areas), create screenshots of every single page visited and generate detailed report at the end of its journey.


Features:

  • Automatically retrieve list of pages to test from xml sitemap file of from Sitecore Item Web API
  • Iterate and verify every single page from the list
  • Create screenshot of every page visited for future inspection
  • Visualize the process in browser as it progresses
  • Run custom JavaScript rules to add additional check for some or all pages
  • Submit forms on the page with test values and verify the result
  • Work with protected areas of websites, that require pre-authorization 
  • Store multiple settings profiles and immediately switching between them
  • Realtime status updates as it goes
  • Detailed stats on execution after test fun finished

References:


Hope you find this tool very helpful!

StackOverflow: Sitecore Development on Mac using C#

Recently came across a question on StackOverflow "Getting started developing with Sitecore CMS on a Mac using C#".

This topic is quite interesting as I am working with Sitecore entirely from my own MacBook for the past few years so I've decided to share my experience with the community.


Being a follower of Apple products I got a top spec MacBook Pro 15" and was willing to make it my primary computer that is always with me and which I can instantly open and start coding. After trying to find the best approach to run the entire Windows server ecosystem on Mac, I turned to virtualisation. The best solution I've found is Parallels Desktop and it brings me better experience than I would expect to get working on a native Windows machine. So what makes this approach so effective?

  • Virtual machine is a file / directory on a disk drive, so copying / archiving allows me to persist current state of each virtual machine with the ability quickly backup and restore.
  • Derived from pervious: I have few pre-configured VMs with Visual Studio, SQL Server, IIS and and Sitecore as well as all development tools I may require. I can immediately return to work even in case of malware preventing me from doing that.
  • Parallels Desktop has tight integration between host and virtual machines. Shared clipboard and resources, it is possible to drag-drop files between Finder and Explorer. Many other sweeties as well are available with Parallels Desktop like Coherence mode, when windows entirely "melts" into mac, with Start button in the doc.
  • Ability to run multiple virtual machine in parallel - as many as your host Ma machine's performance allow.
  • All virtual machines are connected to host mac and each other by a virtual network, so now I am able to create web farms and clusters, sometimes entirely reproducing production environment configuration. Also it is possible to run bridge to external network so virtual machines get network parameters from external DHCP server and will be able to use corporate resources like source control etc. as normal machines would do.
  • Adequate performance and immediate response combined with well thought default settings make it easy to start.
  • Full screen mode entirely simulates usual windows experience
  • Ability to run other operation systems, for example you would want to run a Linux VM with MongoDB at the same network.
The only negative point about Parallels is that it is not free, the rest pretty perfect.

I would especially recommend Parallels Desktop to those who are just beginning working with Sitecore, as their chances to break anything by mistake are high enough, so the ability to create a restore point at every single moment is very beneficial for them.  

Sitecore XP 8 Upgrade for .NET Developers training - how was that?

Last Friday I have attended Sitecore XP 8 Upgrade for .NET Developers training in their London office. Unlike WND (4-days-long) training, to attend this 1-day-long UPG (upgrade) course, you have to already have one of previous full development certification courses done in past.

My major purpose for that training was to get clear understanding about both internals and integration of xDB with the rest of platform, mostly due to the big number of questions I prepared well in advance. I got everything what expected from that day!

There were only 4 trainees in the class; instructor was a guy who works for head office in Copenhagen - Alin Pârjolea - I knew him from community activity previously. Alin was just a bit shy in the beginning, admitting that is was his first time training to such an advanced auditory, but he did well and in an hour we found ourselves very involved in progressing the course and had nice engrossing conversations every break time.

Certification exam itself was typical - 40 questions from which you need to get 70% of correct answers, three options one and only of them is correct. However I found it to be quite complex. Many questions were worded quite confusingly - and the answers also were not quite easy to select from, sometimes we had two answers suiting question, sometimes none, so had to try to read between the lines and try thinking an questioner - what in fact was intended to ask. Also questions were from the whole Sitecore experience, not only what was covered by the upgrade course that day, so those who have little experience in general and little knowledge of best practices are very unlikely to pass that test. All four of us were quite experienced Sitecore developers and all four have passed, I personally got 82% of correct answers.

Also after the course Alin shared with us some best solutions already existing, that was how I knew about Sitecore Habitat - probably the best approach to moduleness, simplicity and extensibility for big and multisite Sitecore solutions.

So, I am quite glad I managed to get certified with Sitecore 8 and do recommend as well!


StackOverflow: Sitecore 8.1 bug - Launchpad brings HTTP 500 errors and several icons including FXM are missing

Question: today I have came across a question on StackOverflow regarding new 8.1 installation, I couldn't pass by:

I am installing Sitecore 8.1 with SIM and get several JavaScript errors coming from ajax request returning HTTP 500 errors when open my launchpad. Looking in the developers tools shows the message:

http://sitecore81/sitecore/api/ao/aggregates/all/786FBA3A4573445EA74504E3CA5E48C1/all?&dateGrouping=by-week&&dateFrom=26-07-2015&dateTo=26-10-2015&keyGrouping=collapsed

http://sitecore81/sitecore/api/ao/aggregates/all/7A9A483F195D4F96AD88473CD6854C4F/all?&dateGrouping=by-week&&keyTop=5&keyOrderBy=visits-Asc&dateFrom=26-07-2015&dateTo=26-10-2015&keyGrouping=by-key

"An error occurred when trying to create a controller of type 'AnalyticsDataController'. Make sure that the controller has a parameterless public constructor."
"at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"


That results to several icons missing from Launchpad, for example FXM.

That is exact point of my confusion I've experienced previous week, when Sitecore 8.1 was released. The explanation is below:

Previously in Sitecore 8.0, there was a very confusing situation, when many new features introduced in 8.0 required license for 8.0. Running those features with a license from one of previous Sitecore version did not block those features in UI from working, but still disabled them from inside of CMS. That lead to some confusing situations like I have described in one of my previous blog posts (see: blog post about FXM and question on StackOverflow) when user without appropriate license ran FXM and couldn't add parent placeholder - no relevant error message was said.

Now since 8.1, Sitecore decided to perform very reasonable structural changes to separate CMS from xDB and Analytics with licensing model. They introduces a new CMS-only mode when Sitecore can run without xDB and Mongo, just CMS features. Those who require to use xDB and Analytics in 8.1 now need to request explicit license allowing those features (using this URL). Otherwise their Sitecore instance will default to CMS-only mode. Sitecore download page contains a warning message regarding those changes:

Sitecore 8.1 now requires a license with the “Sitecore.xDB” key to enable all features of the Experience Platform. If your license file does not contain this key, Sitecore will default to Experience Management (CMS-only) mode. Any customers or partners with a license to Experience Platform should contact their account manager or login to SPN if they are missing this key.
But what about javasript errors? Well, that is definitely a bug. I have previously contacted Sitecore support in order to report a bug (issue Id 451464). Even if you explicitly enable CMS-only mode in Sitecore.xDB.config - you'll still get those AJAX errors. It looks that corresponding SPEAK controls try to call to Entity Services (web API) and it returns generic 500-error (internal server error) code, instead of something more specific like 403 (forbidden) and proper handling that code in JavaScript on client side.

Hope Sitecore fixes that shortly!

Update: I have received confirmation that having a license for xDB in 8.1 this issue does not occur.