Need to do some jQuery work and it's a lot easier with auto complete / code complete.
See my SO answer here.
Enjoy!
Ideas and thoughts about Microsoft Identity, C# development, cabbages and kings and random flotsam on the incoming tide
Thursday, October 21, 2010
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:
It would look something like this:

The csv file is a simple one column list of user Ids.
Enjoy!
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
Stackoverflow
Meta Stackoverflow
Programmers
Serverfault
Food and Cooking
Superuser
Enjoy!
Combined
Stackoverflow
Meta Stackoverflow
Programmers
Serverfault
Food and Cooking
Superuser
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:
The code runs through the spreadsheet until it finds an "Exit" in the URL field.
populateParams looks like:
Enjoy!
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!
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!
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.
I could never quite get this to work.
I use the Firefox Profile Manager.
The command line is:
You need to do this from wherever Firefox is installed on your PC e.g.
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:
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!
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!
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!
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!
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!
\Documents and Settings\
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!
Thursday, June 24, 2010
Misc : Let me Google that for you
"This is for all those people that find it more convenient to bother you with their question rather than google it for themselves."
Go to the site
Type your question and click the "Google Search" button.
Then you can share the link that's generated on the page.
e.g. searching for "Java for loop" generates:
http://lmgtfy.com/?q=Java+for+loop
Go to the link and watch what happens! :-) Now you send that link to the person who bothered you with the question in the first place.
If you hover your mouse over the link on the lmgtfy page, you see a button for "tinyurl" and "go". The first generates a tinyurl as you would expect and the second shows you what happens when the user clicks on the generated link.
Clicking the "Live Stream" at the bottom shows you what other people are searching for and if you click the dropdown at the bottom you can generate the page in a number of languages.
Now bug off and do your own searches!
Enjoy!
Go to the site
Type your question and click the "Google Search" button.
Then you can share the link that's generated on the page.
e.g. searching for "Java for loop" generates:
http://lmgtfy.com/?q=Java+for+loop
Go to the link and watch what happens! :-) Now you send that link to the person who bothered you with the question in the first place.
If you hover your mouse over the link on the lmgtfy page, you see a button for "tinyurl" and "go". The first generates a tinyurl as you would expect and the second shows you what happens when the user clicks on the generated link.
Clicking the "Live Stream" at the bottom shows you what other people are searching for and if you click the dropdown at the bottom you can generate the page in a number of languages.
Now bug off and do your own searches!
Enjoy!
Subscribe to:
Posts (Atom)