Creating web performance tests in Visual Studio for SharePoint on premise is easy and well documented. But writing them for Office 365 / SharePoint online is another thing. The authentication can be different – depending on you configuration – and there is nearly no documentation available. In my case the SharePoint Online tenant authenticates via ADFS against a Windows Active Directory Domain.
The easiest way to get the authentication running is to record the authentication flow in Visual Studio. Before you start recording the web test, open your browser and make sure you are logged off from Office 365. Then record the login process to your site and edit the web test.
The first thing you have to do is to set your credentials for the test in the properties windows.
Now find the request to your adfs that ends in /adfs/ls/. Delete all the steps before that – you don’t need them. Remove the referrer and make the url to your adfs, the client request id and the user name context parameters. The extraction rule should be correct.
The next request you have to look for is a post to login.microsoft.com/login.srf. Delete all requests between the adfs and this one. Remove the referrer. The form post parameters should be correct – if not you have to adjust them according to the image.
The next thing we have to do is a post to /_forms/default.aspx on your SharePoint. This post will redirect you – so make sure to set the expected response url correctly. If you leave this step out you won’t get the authentication cookie!
Visual Studio will now add the cookie to every request. Delete all the other requests and add a new GET request to your desired page.
To make sure you don’t get redirected you should add a validation rule and validate something on your site. I added a rule and test the site title.
If you run the test and encounter errors, check that the Set-Cookie ist set correctly after calling the login.srf. It must be in any request.
I just started testing SharePoint Online and Office 365 for different customers. So expect more posts to this topic the next months. What’s your experience? Do you use automated tests for SharePoint online?