David Walker | 21 June 2012
I could just leave it at that because wow its shocking enough!
Out of those that do test many do this:
Please, please do not do this an alert It is a modal alert box which freezes the UI but does not freeze anything else so if you had say some AJAX or a timer on the page it would not freeze those operations. As a result it may cause your test to become skewed or even cause other errors.
To bring up the developer console in any page you can right click on the page and chose inspect element. On windows you can also press F12 on a Mac command-option-i.
You'll see something similar to this:
If you've not used it before take a look around but for what we are about to do you need to choose console.
In your HTML editor of choice create a page and enter the following script:
var x = 5;
console.log("The value of x is: " + x);
Your editor may be giving you warning about console not existing by the way. Ignore them as Chrome does understand the script.
If you open the page in Chrome at this point (reopening the editor if necessary) you should get a message saying 'The value of x is: 5'.
The console.log method is an extremely useful tool allowing you to capture variables or write messages to the developer console without artificially interrupting the UI with alert boxes.
In part 2 of this series we will examine trapping objects as part of the debugging process