Fluent Bytes

"The only source of knowledge is experience" - Albert Einstein-

Page 4 of 16

Solving intermittent DNS issues
on your custom Azure
development domain

The past few weeks I have been working on my own development domain, hosted in windows azure. There is a nice step by step plan available online on how to set up a network that can host your own development machines and your own domain controller, so you can use all these machines as if they run in one domain. (http://azure.microsoft.com/en-us/documentation/articles/active-directory-new-forest-virtual-machine/)

Setting up such a domain is especially useful when you want to leverage e.g. TFS and the test tools, since these tools work best if you work in a domain joined environment.

After setting this up, all worked great and I have used it for several demos and just some average development work I do.

My network looks more or less as follows:


But all of a sudden last week, I ran into the problem that on any of my development machines (the test clients) could not connect to the internet anymore. Sometimes an address was reachable and all of a sudden a couple of seconds it was not possible to connect. This intermitted problem was really problematic getting any real work done these days especially when you are running tests against websites on the internet Smile

So trying to resolve the problem, I first looked at my network setup and especially DNS. Reason for me to start there is that the IE browser constantly showed the dreaded connection failed and telling me I did not have an internet connection. If you look a bit deeper, you could see it was a name resolution issue, so I started a command line and used nslookup to try to resolve names.

the results for such an lookup looked as follows:

> google.com
Server:  UnKnown

DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
*** Request to UnKnown timed-out

So this confirmed to me I had a DNS problem, question next was how to resolve it. With the custom domain setup, I configured a virtual private network with the address range 10.0.0.x and since I wanted to host my own Active Directory  and you can see by the response it did pick up my DNS server. So the problem must be at the DNS server itself.

Then I looked at the DNS configuration and since it was fully functioning before, it must have something to do with a DNS setting that might have gone stale in the Azure network topology.

One of the things that is different to on premise AD is the fact that your AD machine still has an DHCP obtained address. I did pin it to a fixed address using the PowerShell command described, but still you get this address from a DHCP server.

Now looking at the configuration, I discovered that the configured forwarder, that takes care of all requests outside the local domain, was unable to resolve.


After posting a request on the azure forms, to get some help, I got a response that was very helpful. It pointed me to the following article: http://windowsitpro.com/windows-azure/solve-dc-name-resolution-problems-azure

This was exactly my issue, so by removing the forwarder, DNS will fall back to the root hints. Now all requests can be resolved straight away and my development machines can happily browse the web again Smile

I Assume this problem is caused by the fact that once I created this AD machine and promoted it to the AD and DNS server, it just added the DHCP server that it got it’s lease from as the default forwarder. Since I might have been moved around the datacenter during maintenance or perhaps even failover, it is very well possible this server does not exist anymore. By just removing it from the list, I have a more sustainable solution, since it will not be affected anymore by such a move in the future.

How to faster close a browser tab when using CodedUI

Last week I got contacted via twitter (@marcelv) with the a question regarding my Pluralsight CodedUI course and a previous blog post that shows how to use CodedUI to test applications that use multiple tabs in the browser.

This particular question was, how can I close the browser tab faster since using the BrowserWindow.Close() function takes a lot of time.

To give some more context, in this blog post you can read how to access a newly created browser tab in your test.

Now when you have found the new tab, you have a reference to that tab. This reference is a BrowserWindow class. This class has the close method on it, but if you call the method to close the tab, this can take quite some time. On my machine times varied between 8 and 14 seconds before the tab was closed. If you have an application that has a lot of tabs that you need to test, you can imagine test times add up quickly.

So how does the code look like if I close the tab using the BrowserWindow class


So what is the alternative, and how can I close the browser window in just a matter of milliseconds?

Well this is the area that CodedUI shines in my opinion (Besides the point that the close takes way to much time, which is of course not cool at all!). With CodedUI I can very easily switch UI technologies while still using the API. What I mean by that is that in stead of using the browser window and HTML controls that use the web technology driver to find element, I can just switch to using Windows Controls, that uses MSAA to access controls on a windows desktop,  and manipulate those in order to achieve my goal.

In this particular case, you need to find the tab strip in the browser window and in the tab strip find the tab you want to close. If you run your test in internet explorer, the tab contains a close button that you can then find and click.

The following lines of code achieve this goal (assuming the tab has the title “New Tab” as with the example in my previous post):


So what is the difference in speed her?

Well using the BrowserWindow class it took between 8 – 14 seconds to close the tab, with the alternative approach using windows controls it takes about 500ms.

there is a downside to this approach that you need to be aware of, when you run multi browser tests with the selenium plugin that MS provides via the visual studio code gallery, you need to be aware of the fact that using the BrowserWindow class works cross browser and using the alternative only works for the browser you design the close for. So if I want to achieve the same on Chrome or Firefox, then I need to figure out which windows controls they use for their tabs and how I can click the close button there as well.

Hope this helps


How to work with symbolic link files under Linux/Unix and TFS?

With Team Explorer Everywhere you have the ability to use TFS from the command line on any Unix/Linux system. One of the features of the Unix/Linux file system is that you can use so called symbolic links. These are files that more or less work the same as a shortcut, they point to another location on the file system where you can find the actual file. You could also call it a moniker.

This type of file is often used to share a common set of files from another location in the file tree on different other locations of the file system. It is a way to handle dependencies e.g.

Lets assume you have such a system, and you want to place it under Team Foundation Server Version control, how can you make this work?

Welcome in the wonders of .tpattribute files.

.tpattribute files get their name from the early days of Team explorer everywhere, the company where this was first build. Team Prise. a .tpattributes file is just a text file that can contain the definition of a symbolic link. this definition is then used on a get operation in that workspace to be applied to a certain file so it becomes a symbolic link.

In the past (before Team Explorer Everywhere 2012) you also used these files to set for a set of files e.g. the execute bit on a get operation.

the contents of the .tpattributes file is described very shortly here: http://msdn.microsoft.com/en-us/library/gg413272(v=vs.100).aspx

Lets use an example to clarify its usage:

Lets assume we have the following symbolic link we want in our workspace:


It points to:

site_config -> ../client/bin/site_config

For this to happen on a TF get command, we need the .tpattributes file to contain the following information:


When we have created this file we check it in. But that is not all to make it work! In order to actually make the magic happen we also need a file in version control as the placeholder for the symbolic link file. Easy way to do this is by deleting the symbolic link file and then recreate a new 0 bytes file with the touch command.

then we check in the .tpattributes file and the 0 bytes placedholder file, site_config in our example case.

Now to see the magic happen, we can set up a new directory and workspace mapping and then execute a get operation on that folder. What happens is that it will get the .tpattributes file and when that is on local disk, will be used by the tfs client to apply the symbolic link to the file site_config.

So the moment you get the site_config file, team explorer will convert it to the symbolic link. this can be easily verified by executing a ls –all command and then you can see it point to another file.

This symbolic link will not be set up when the file it points to is not available.

Another thing to note is that in the past the .tpattributes file was also used to set the execute bit on files. you could do this by starting the file with e.g. the following regular expression:


This then resulted in all files in that directory to get the execute bit applied.

Now I have experienced that sometimes when your file starts with this syntax to set the execute bit on a certain set of files, sometimes the symbolic link is not created. the solution is that you remove this part from the file. the reason that can be done is that TFS will keep track of the the execute bit status on a file and when executing an add it will add this information with the file in TFS. when you get the file on a Unix/Linux system, then TFS will restore the execute bit without the need for the .tpattributes file.

Hope this helps, I can tell you it took me quite a while to get this figured out.

I will be speaking at TechEd
Europe 2014

At TechEd Barcelona this year I will deliver a talk on “Best Practices for Using OSS in the Enterprise“.

Session abstract:

Most of us understand the benefits of using open source software and libraries. Heck, even Microsoft embraces it, so why can’t you adopt it as well in your enterprise? Open source can be a blessing and a curse at the same time. We probably all remember incidents like the “heart bleed” vulnerability in a popular open source implementation of SSL. So, if open source becomes more and more prevalent, how can we cope with the challenges that lay at hand? We will be challenged with all sorts of questions in the enterprise: What are the license implications when I take a dependency on a library with a viral type of license? What version of open source libraries are we using and are they the choice of the generic public or did we select one we now need to maintain ourselves? Are there known vulnerabilities in the libraries we use, and if so, are we affected by that? In this session, we take a practical approach to using open source libraries in product development for the enterprise. We touch briefly on the license types and the ones to look out for. We show you how an artefact repository system can help you to answer a lot of the tough questions. Learn how to integrate a system that is very popular, called Nexus, in your continuous deployment strategy and ensure a frictionless experience for your developers. We show integration with NuGet and how to manage open source dependencies using proxy facilities so you can ensure only a curated set of libraries are used, and meet compliance requirements for your business.

Of course you can find me also at the ask the experts booth as well.

If you want to drop by and have a chat, my schedule looks as follows:

Tuesday, October 28
9:00 AM-10:30 AM
Keynote Session, Hall 6
11:00 AM-12:00 PM
Foundational Sessions, various rooms
6:00 PM-8:30 PM
TechExpo Welcome Reception, Hall 7

Wednesday, October 29
8:00 PM-11:00 PM
Country Drinks, Barceloneta Beach

Thursday, October 30
4:00 PM-5:00 PM
TechExpo Happy Hour, Hall 7
6:30 PM-8:00 PM
Ask the Experts, Hall 5

Friday, October 31
2:45 PM-4:00 PM
Best Practices for Using OSS in the Enterprise


Creating a detailed test report
showing results of test case steps

For a while I have been working on a fairly large implementation of Team Foundation Server. During this implementation we phase out several silo based systems, like rational tools and HPQC. Moving from HPQC to MTM and TFS has been rather easy if you understand that the two systems just have a complete other way of treating test cases and test runs. To Satisfy some end user data needs we needed to create a custom report that is similar to the reports that can be created with HPQC out of the box. This is the test detail report, which I added here below to see what it is about. clip_image002 As you can see it shows not only the test suite outcome, but also the outcome of the test case and the detailed steps and where things failed. Creating a report as above, apeared to be more challanging then I thought at first, but that has to do with the fact that the standard solution we have, don’t have all the data we need. Work item queries, don’t have test case results. The data warehouse contains data to the test case run level, but not the step details. So how can we fix this? Apparently my fellow MVP Tarun Arora (http://geekswithblogs.net/TarunArora) had an excellent post (http://geekswithblogs.net/TarunArora/archive/2011/10/02/mtm-testing-scorecard-using-tfs-api.aspx) that got me out of the gate towards a solution. What he did is just create a simple windows forms application that uses the TFS API to get to all the data. So while less ideal, we can have a solution, but unfortunately not one that integrates out of the box. So I picked up the sample code from Tarun and altered it in such a way that it would give full details on test runs and render them using an embedded report viewer control. The only alternative to get this data is using the TFS object model. In the object model I can get to all the details I need, by using the ITestManagementService. So when you want to get to the test details, you first need to understand how the relationships are set up in the API. So first let start with understanding the basics, and then dive into the solution.

1.1 TFS and MTM ITestManagementService data

To get access to the service we use the standard pattern of connecting to TFS and then requesting the service we need.

Now that I can get to the service, we need to walk the hierarchy. We have a Team Project and a Team project can have multiple test plans. A Plan has the notion of Test Suites and a suite can be either a static suite, a Query based suite or a Requirements Based Suite. Now the tricky part is that a test case is a work item that can be associated with multiple test suites and a test suite can contain multiple test cases. The following diagram shows the relationships.   image Now this model is the logical setup when you look at how you create a test plan. The moment you want to execute a test, we need to add some additional things to the mix. Test runs are a mixture of Test suites that contain test cases and based on the selected configurations we want to run for. So if you start to look at test results, the data structure is a bit more complex. So For our report to succeed, we need to retrieve the following data:

  • For a selected team project ( a dropdown selection in the tool) and a selected Test Plan (Also a drop down selection) we are going to retrieve the test suites.
  • Then for each suite we need to get the test cases and for each test case we need the test results.
  • These test results can be found by using a concept call “Test Points”. A Test Point represents a Test Case to be run against a Test Configuration in a Test Suite.

The results become even more complex, since we can execute a test that contains test cases with parameters (using the @ symbol to denote the parameters in the test steps) and this will result in multiple iterations of the same test steps. The below picture shows the result structure we need to use to get the right data: image So as you can see it involves quite some iterations to get to the final data we want. What I have done is used the solution Tarun build and extended it to support my needs. I had to alter some of the functions that get the test suite hierarchy and the actual function that retrieves the data and creates dataset that can be fed into the report viewer control. To give you an example of the results, I have a couple of screenshots to show you how it looks. You first create a test plan in MTM, like this: clip_image008 You can see I have a test plan with several test cases in there and I ran a set of manual tests so all my tests have some test results associated. Now when you start the report tool, you need to connect to your TFS server image After you connect, you select the team project and the plan you want to view the results from. image When you selected them, click the generate report button, and it will get the data from TFS image Next you can see the detailed report with all test suites, test cases per suite, per test case the iterations and per iteration the test steps and the result of each step. As a bonus, I added also the capability that when you are using parameters in a test case and have multiple iterations on a test run, you get the parameter values that were used in a run as well. Smile clip_image016 I thought it might be useful for others to use as well, so I placed this work on codeplex. Now everyone can contribute. The codebase is not the greatest code in the world, but it gets the job done for me at the moment. Feel free to make changes and tidy things up as you use the tool yourself. I love contributions Smile You can find the project here: https://tfstestreport.codeplex.com/ If you want to join, please let me know and provide me your login name at codeplex when requesting. Hope this helps, Marcel

I’ll be speaking at Live! 360,
November 17 – 21 in Orlando, FL

I thought you might be interested to know that I’ll be speaking at Live! 360, November 17 – 21 in Orlando, FL.  Live! 360 brings together five conferences, and the brightest minds in IT and Dev, to explore leading edge technologies and conquer current ones. More info: http://bit.ly/LSPK23HOME
I’ll be presenting the following sessions:
together with Rockford Lhotka, CTO, Magenic I will be dong a full day workshop.
I will also present the following sessions:
  • Automated Cross Browser Testing of Your Web Applications with Visual Studio CodedUI  
  • The Road to Continuous Delivery, Automated UI Testing for Web, WPF and Windows Forms  
SPECIAL OFFER: As a speaker, I can extend $600 savings on the 5-day package. Register here: http://bit.ly/LSPK23REG and use code LSPK23.
Get better at what’s available, and get ready for what’s coming. We delve deep into the topics that matter most in your world today, covering practical knowledge, fundamentals, new technologies, and futures.  Register now: http://bit.ly/LSPK23REG

Bulk updating work items with TFS 2012 and above

One of the less well known features of TFS work item tracking is that there is an option to edit multiple work items in bulk. This is especially handy when you have e.g. a set of user stories that you want to link to one feature or if you want to update a set of fields all in once on a set of selected items.

How can you do this?
Simple, first you need to create a query that results in a list of work items. You can see a screenshot here below that is taken on the TFS service, but this works on TFS 2012 and above.


The next thing is that you select the items you want to update using either the ctrl key to select individual items or the shift key to select a range of items. At the moment of selection you will see a little glyph in front of the selected rows. This glyph contains a menu and there you can choose for the bulk update commands. See screenshot below:


When you select the Edit selected Work item(s), then you can pick one or more fields you want to update in one go.


After you are done, you will see all items are shown in bold, indicating something has changed on these items. To save your changes, you need to hit the save all button and done, all your items are updated in one go.


You can also use this same functionality to link all selected work items to a new or existing work item in TFS.

This is just one of those features that is very well hidden in the system and can save you a ton of time Smile

Hope this helps


How to access the src property of an IFrame with CodedUI

This week I got a request via twitter (@marcelv) if I could help out on an issue with CodedUI. The person had watched my course at Pluralsight on CodedUI and wanted to know if it was possible to change the src property of an IFrame with a CodedUI test.

So the code he had was something along the following lines:

The problem he ran into is that this code will throw an exception the moment you try to set the src property. It will throw the following exception:
System.NotSupportedException: SetProperty of “Src” is not supported on control type: Frame

One thing I tried is to use frame.PageUrl, but that does not work, since the property is marked as read-only, so that code will not even compile.

I think it is a bug in the codedUI object model, but the question is how can I fix this in the meanwhile?

The solution I have to this is the following:

Either create a JavaScript and use BrowserWindow.ExecuteScript to change the property, or change the property using the native element. The later is done as follows:

Now this solution works, but be aware that this is an IE Only solution. Here I am using COM interop behind the scenes to interact with the IE DOM to make the change to the property. If you would like to keep the capability of cross browser testing, you might be better off using the JavaScript option instead.

Hope this helps

Switching browser in CodedUI or Selenium tests based on MTM configuration part 2

More then a Year ago I wrote a blog post on how you could switch browsers based on the configuration settings in MTM. You can read more about that in this post here:http://bit.ly/1AKeFAS

So this solution unfortunately works partially and I have talked with the TFS team about this for a while but this is something that might take a while to get fixed. This week someone asked me again about this solution and I worked on a work around to get things running the way we need.

So first, what is the problem?

When you run one test case all will run fine. the Test Context will contain the right information and you can use the configuration name that is passed in the __Tfs_TestConfigurationName__ property from the TestContext.Properties collection.

But when you do a multi select of some test cases you want to run or you run a full test suite, you will run into the issue that the information being passed in the TestContext Properties collection becomes stale after the first test case is done. So if you look at the screenshot below, you can see that I picked 3 test cases to run:


When you look at the results (this test just dumps out the properties in the collection to see what is in there) you can see that for each run the configuration has the same value Confused smile:


After reporting this back to the team, this was confirmed as a bug and was not fixed in the recent versions and updates.

How to solve the issue?

So how to solve this problem, so we can really switch the browsers based on the configuration in MTM?

the post here really helped me on my way to get this issue fixed: http://blogs.msdn.com/b/aseemb/archive/2012/08/07/code-snippets-on-test-management-apis.aspx (code snippet #7)

The solution is that we need to query the TFS server on the current test run and based on the current __Tfs_TestRunId__ that is the same for all iterations. Then we can ask for the Test Results for the current test that is running on the current machine. In the test results we can then get the Configuration information of the current running test and that will reflect the real configuration of the current iteration of the test we are running.

to make this work I needed to write up a bit more code then I anticipated, because the Test Result data is reported back to TFS once every 30 seconds and when you start a new run, you might get the data of the previous run, since TFS might lag behind a bit. So I needed to come up with a waiting pattern and only get the data when the test identifier changes, so I know we are in a new fresh run. The code I wrote makes one big assumption and that is that the tests are run in the same process, since I am using a static variable to contain the last test id. This is not pretty code, but it gets the job done.

Here is the code on querying the server and get the right configuration data:

After you have this code, you can now use this function to switch the browser for you in your test by passing it in the Testcontext.

For example in codedUI you can switch the browser now as follows:

BrowserWindow.CurrentBrowser = GetRealTestConfigName(TestContext);

If you now look at the results of the same test run you can see the code finds the right configuration. You can see in the screenshots below it will now really find the actual configuration we are running.


One issue I found with this solution is that your tests will experience a little delay, because we need to wait for the test run to show up in the TFS server, before we can query the data. But if you look at this you might not really find it a problem since it normally is only a small portion of the time spend on a test. These tests are not meant to be a fast unit test, so I guess we can live with it for now.

I sure hope this will eventually get fixed in the test infra structure. If that happens I will post back with that solution.

Hope this helps,


How to find controls in new Tabs of your browser with CodedUI

One question I got recently is if it is possible to find controls on secondary tabs that are created by an application when using CodedUI. the answer is yes and I thought it would be handy to write up how to make this happen.

For purpose of the sample I create a simple ASP.NET MVC website and changed the default page to have a link button that creates a new page in a second tab.

The page looks as follows:


When I click the button, then a new tab is opened and that will show the following page:


As you can see I have done a lot of work to make the page look pretty Smile but that was not the purpose, it is to get the point across how to find the Html on the second tab.

The way you do this is as follows:

  • You first start your test, by using the BrowserWindow class and call Launch to start the browser.
  • Next you find the HtmlHyperlink to execute the click on the button.
  • Now you have the second tab show up, and to locate that tab, you can use the BrowserWindow class again. this time you use the static method Locate and pass it in the title of the document you try to find. In my case that new tab has the Title “New Tab”
  • This locate method, returns a new BrowserWindow object that I can use in my subsequent searches for controls. So to find the text on the page I can create an HtmlDiv object, pass it in the SearchProperty Id with the value of “itemToFind” and get the InnerText value of the control to assert in my test.

The code looks as follows:

And that is it, this is the way to create tests that can work with with multiple tabs in your browser

I have the sample project up here for you to download and test yourself.

If you want to learn more about CodedUI and how this technology works, you might want to check out my course at Pluralsight on CodedUI. You can find it here and even watch it for free if you don’t have an account, by applying for a Trial.

hope this helps,

« Older posts Newer posts »

© 2019 Fluent Bytes

Theme by Anders NorenUp ↑