You learn something new everyday, and sometimes you learn that you don’t really understand some fundamental things. So, let’s share johnny the developer’s ignorance.
Background: I was setting up some WatiN automated acceptance tests for an older Asp.NET Web Forms site.
<digression> I was using WatiN because I’ve used it before, but it looks like it hasn’t been updated in a year. Is it no longer an active project? Should I be looking at WebDriver instead?</digression>
WatiN natively uses a lot of magic strings, and so there is a lot of ‘opportunity’ to fat finger stuff, and of course, that’s what I did. I was doing something really basic: setting up a test to ensure that when the value of DropDownList1 changed, the items in DropDownList2 were repopulated properly. Since I fat fingered the control to look for, the test failed.
Not seeing my obvious typo, I did a view source of the page. Blink. WTF. The view source did not show what was actually rendered. I called over another of the web developers, and he too was surprised at this.
Another developer asked if I was using an UpdatePanel. I didn’t create the site, but yes, that is something that was being utilized, but that still didn’t make sense to me. Shouldn’t the view source reflect the state of the page after all rendering was done?
Turns out the answer is, well, no. As Johnny Carson might have said, I….I did not know that <digression>To the kids out there, you see, Johnny Carson was this famous TV personality who….oh never mind</digression>. When content is dynamically updated in a page through AJAX, Javascript, etc. in many browsers, ‘View Source’ simply doesn’t reflect it. There are other ways and various tools you can use to see the underlying ‘source’, but view source isn’t reliable.
Like the other developer I asked, it isn’t something that I had ever looked at before, and never thought to question it.