Today I created a web test and ran it successfully in my local machine. I implemented it in TFS build, and after queuing the TFS build, the test failed.
Therefore, I logged in to the build machine (Windows Server 2008 R2 SP1) and hit the URL. The following dialog box appeared:
Content from the Web site listed below is being blocked by the Internet Explorer Enhanced Security Configuration.
That explains why the test failed in TFS build.
I put this site in my trusted site and the dialog box still showed up.
After looking into this issue, I need to do the following things:
Click Server Manager
Click Configure IE ESC
In the Administrators section, click off
After that, the test passes in TFS build.