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?
Wow, I wonder why others haven’t written about this a lot!
Thanks a lot Michael, highly appreciate this walkthrough.
I do automated testing but this is something which I have never tried!
Can we do load tests for Office 365?
Yes. You can use the web test described here to perform load tests.
Thanks for that post, how can I do that same thing but for PowerBI (cloud) instead of SharePoint. We have the same setup adfs/ls and login.srf. Did the steps (excluding post to /_forms/default.aspx as it’s not Sharepoint)…
So you want to create a web test for power BI?
Yes exactly we have a SSO setup.
Response URL: Validation The value of the ExpectedResponseUrl property ‘https://app.powerbi.com/’ does not equal the actual response URL ‘https://powerbi.microsoft.com/en-us/landing/signin/’.
So it means it’s not logging in because we are getting the “signin” page instead fo the landing page
Haven’t tried that – but you should be able to record the oauth flow like I did with SharePoint.
That’s what I did, It actually recorder twice the adfs/ls (then I deleted one of them so that it looks like yours). I don’t think that the login.srf is passing on the info to the next step (https://powerbi.microsoft.com/landing/signin/), is there a way to test that?
You have to check where it redirects you to do the post. The key in the SharePoint scenario was the post to forms.aspx. PowerBi should redirect you to an similar page.
Thanks for the tip ill try to focus on that