Friday, October 22, 2010

IE : Fixing the "Do you want to view only the web page content" popup

The most annoying part of Internet Explorer (IE) 8 is the "Do you want to view only the webpage content that was delivered securely?" popup that forces you to continually click "No".

Maybe it's useful when doing Internet banking but I get it every time I open up Blogger. Why wouldn't I want to see the whole page?

The solution is simple:

Tools / Internet Options / Security / Custom level / Miscellaneous / Display mixed content

and change the option from "Prompt" to "Enable".





Reply "Yes" to the "Do you want to change this option?" question and OK out.

Problem solved.

Enjoy!

Thursday, October 21, 2010

Netbeans : jQuery code complete / auto complete

Need to do some jQuery work and it's a lot easier with auto complete / code complete.

See my SO answer here.

Enjoy!

Wednesday, October 20, 2010

JMeter : Reading variables from a file

Done a lot of load testing with JMeter.

Quite often, I need to try load testing for lots of user logins. To do this you can't hard code the value in the form - you have to somehow read it from a file.

Enter JMeter's String From File

"The StringFromFile function can be used to read strings from a text file. This is useful for running tests that require lots of variable data. For example when testing a banking application, 100s or 1000s of different account numbers might be required."

For a field called userId, enter something like the following in the Value column:

${__StringFromFile(x:\Path to csv file.csv,userId,,)}


It would look something like this:




The csv file is a simple one column list of user Ids.

Enjoy!

Thursday, October 14, 2010

Stackoverflow : Flair

Playing around with my StackExchange "flair"



Combined



profile for nzpcmad on Stack Exchange, a network of free, community-driven Q&A sites



Stackoverflow



profile for nzpcmad at Stack Overflow, Q&A for professional and enthusiast programmers



Meta Stackoverflow



profile for nzpcmad at Meta Stack Overflow, Q&A about the Stack Exchange engine powering these sites



Programmers



profile for nzpcmad at Programmers, Q&A site for expert programmers interested in subjective discussions on software development



Serverfault



profile for nzpcmad at Server Fault, Q&A for system administrators and IT professionals



Food and Cooking



profile for nzpcmad at Cooking, Q&A for professional and amateur chefs



Superuser



profile for nzpcmad at Super User, Q&A for computer enthusiasts and power users



Enjoy!

Selenium RC : Using a spreadsheet with Selenium

Quite a lot of the work I've done with Selenium is very repetitive e.g. navigating to an application, logging in, doing some test and logging out.

It made sense to put this in some kind of spreadsheet where each line would have the application URL, login credentials (user field name, user name, password field name, password) and the name of the "Submit" button. Then do some application work perhaps and then logout.

The program could go through the spreadsheet row by row populating the values and then posting the page.

I put all the data into a csv file so I could use opencsv to read the rows.

The code looks something like:


CSVReader reader = new CSVReader(new FileReader("x.csv"));

while ((nextLine = reader.readNext()) != null)
{
populateParams(nextLine);

if (!csvURL.equals("Exit"))
{
selenium = new DefaultSelenium( "localhost",
4444,
"*iexplore",
csvURL);

selenium.start();
selenium.windowMaximize();

selenium.open(csvURL);

selenium.waitForPageToLoad("30000");
selenium.type(csvUserText, csvUser);
selenium.type(csvPasswordText, csvPassword);
selenium.click(csvSubmit);
selenium.waitForPageToLoad("30000");

...
}


The code runs through the spreadsheet until it finds an "Exit" in the URL field.

populateParams looks like:


public void populateParams (String nextLine[])
{
...
csvURL = nextLine[1];
csvUserText = nextLine[2];
csvUser = nextLine[3];
csvPasswordText = nextLine[4];
csvPassword = nextLine[5];
csvSubmit = nextLine[6];
...
}


Enjoy!

JMeter : Setting up a HTTP Proxy to capture traffic

You can build up a JMeter test plan yourself but it's much easier to set up a proxy and let JMeter do all the grunt work for you.

There are some JMeter proxy Step-by-step instructions here.

If your environment has a proxy you need to tell JMeter about it via the command line e.g.

jakarta-jmeter-2.4\bin>jmeter -H yourProxy.co.nz -P yourProxyPort

The basic idea is that you change your browser settings to point to the JMeter HTTP Proxy and then the JMeter proxy forwards the packets to the real proxy configured in the command line.

To setup the JMeter proxy after you have started up JMeter, right click:

WorkBench

Add / Non-Test Elements / HTTP Proxy Server



Choose a spare port (in this case 9090) and configure in the Port box.

Now you need to change your browser settings. Use

Tools / Internet Options / Connections / LAN Settings / Proxy Server

Set the proxy server to localhost (or 127.0.0.1) and the port number to 9090.

In JMeter, right click Test Plan / Add / Threads / Thread Group.

Doing this forces the proxy to capture the traffic inside of the plan.

Now click on HTTP Proxy Server and click Start at the bottom.

Now open your browser and browse to the URL you want to test.

In JMeter, you should see something like:



Note that it's a good idea to add a HTTP Cookie Manager as well as this enables cookies to pass between pages.

Enjoy!

Wednesday, October 13, 2010

Selenium IDE : Input too "early"

I've seen this behavior a number of times.

You run a Selenium IDE script where you have a

waitForTitle
type - token - text

scenario and Selenium will complain that the field "token" does not exist.

But it does - at this point, you are staring at it in the browser.

What sometimes seems to happen is that the page loads, Selenium sees the title and moves to the next line of the script but the actual fields haven't loaded yet and so can't be found.

The way around this is to look for a bit of text near the input field and then do a

waitForTextPresent

That way the input field is there when the script requires it.

Enjoy!

Selenium RC : Setting up a Firefox proxy

The normal way to use Selenium RC if your environment has a proxy installed is to use the command line e.g.

java -jar selenium-server.jar -Dhttp.proxyHost=xxxproxy.company.nz -Dhttp.proxyPort=8082

I could never quite get this to work.

I use the Firefox Profile Manager.

The command line is:

firefox -P


You need to do this from wherever Firefox is installed on your PC e.g.

x:\Program Files\Mozilla Firefox


When the "User Profile" box pops up, choose "Create Profile" and follow the wizard.

Run the command line again and select the new profile and then select "Start Firefox"

Configure Firefox to use a manual proxy:

Tools / Options / Advanced / Network / Settings

Configure the manual proxy to point to the proxy in your environment.

The Selenium RC command line you need to use this is:

java -jar selenium-server.jar -firefoxProfileTemplate "Path to profile created above"


GOTCHA: Remember to run the Profile manager again and select "default" to return to your normal profile otherwise any new changes will be mode to the wrong profile.

Enjoy!

Tuesday, September 28, 2010

Excel : Pesky hyperlinks

I hate the fact that Excel automatically changes a URL to a hyperlink when you click on it or want to cut and paste.

To get round this abysmal behaviour (I have Excel 2003):

Tools / AutoCorrect Options / "AutoFormat as you type" / Uncheck "Internet and network paths with hyperlinks".

Another way is to simply type an apostrophe in front of the URL.

If you already have the damn things, you can right click and "Remove Hyperlink".

For multiple ones (as per the Help file):

Type the number 1 in a blank cell, and right-click the cell.
Click Copy on the shortcut menu.
While pressing CTRL, select each hyperlink you want to deactivate.

No more damn hyperlinks!

Enjoy!

Wednesday, August 18, 2010

Visual Studio: Fiddler and Team Test web test

Noticed that the amazing Fiddler has the capacity to generate Team Test web tests for you.

See here.

Aside: Note the comment further down the page:

"Please see http://blogs.msdn.com/slumley/pages/how-to-debug-a-web-test.aspx for information on how to troubleshoot problems with WebTests".

Very useful link!

Enjoy!

Visual Studio

I've been playing around with Team Test 2008 running on Windows 7.

When I try and capture a web test, the browser would lock up with the comment:

"The web test recorder must be launched from within Visual Studio".

WTF, I am within Visual Studio!

Mr. Google to the rescue and the solution is that you have to run VS with administrator rights.

Right-click on the shortcut / Properties / Compatibility / Check "Run this program as an administrator".

Problem solved.

Enjoy!

Friday, July 30, 2010

XP : Profile keeps filling up with Sun cache

Had a problem with my profile always being fill with Sun cache files i.e. files under:

\Documents and Settings\\Application Data\Sun\Java\Deployment\cache

The easy way to clear these out is to click on the Java Control Panel in Control Panel.

Under the General tab / "Temporary Internet Files" / Settings / "Delete Files"

You can also vary the amount of space these files use by adjusting the slider on that page.

Yup - tons more profile space.

Enjoy!