Thursday, January 28, 2010

Watir -Click_no_wait() does not trigger the Popup window

Due to Click_no_wait() does not work on my IE, based on the discussion and suggestion from this thread:http://jira.openqa.org/browse/WTR-320 , I have to roll back my ruby version from ruby186-27 to ruby186-26, here is my process:

1. Uninstall ruby186-27
2. Install ruby186-26
3. Run "gem update --system"
But Shit happens:
...
rubygems-update requires builder >= 0


4. manually download rubygems-1.3.5.zip
5. upzip rubygems-1.3.5.zip to C:\
6. Run "C:\rubygems-1.3.5>ruby setup.rb" --RubyGems 1.3.5 installed
7. Run "gem update --system" --Nothing to update
8. Run "gem install watir"

Done. i will see if it works now...God bless!
-- update , it did works! :)

Updated from 2010/09/25:
It has fixed this issue on ruby186-27 now, i have not tried that yet:
http://jira.openqa.org/browse/WTR-320?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Monday, January 25, 2010

Regular expression in Watir method

We can make usage of regular expression in Watir to easily access the dynamic object, for example:
you want to pick a option in select_list which id is : hello_12345, 12345 is dynamic number, so you can write like this:

cframe.select_list(:id, /hello_\d+/).select("Select one option");

Sunday, January 24, 2010

Memory Pool--Code Cache can be "GCed"

The code cache GC has been detected :)

Open expire headers to reduce 304 requests

Open expire headers on Apache http server:

[IfModule mod_expires.c]
ExpiresActive On

ExpiresByType image/* "access plus 30 days"
ExpiresByType application/x-javascript "access plus 30 days"
ExpiresByType text/javascript "access plus 30 days"
ExpiresByType text/css "access plus 30 days"
ExpiresByType image/x-icon "access plus 360 days"

[/IfModule]


before enabling Expire header:


After enabling Expire header:


you can see all of the static files, like images, .js and .css are read from browser cache directly instead of sending additional requests to the server and get 304 not modified response status code. it improves our performance and saving bandwidth as well.

Thursday, January 21, 2010

Enable Gzip on Apache Http server

Enable Gzip, modify the httpd.conf:

Apache Httpd.conf change:

LoadModule deflate_module modules/mod_deflate.so

LoadModule headers_module modules/mod_headers.so

.....

#Enable Gzip



# we do not need to 9 level, due to CPU% is high but no further compression benefit
DeflateCompressionLevel 7



# Insert filter
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/javascript application/x-javascript

AddOutputFilter DEFLATE css js


# Netscape 4.x has some problems...

BrowserMatch ^Mozilla/4 gzip-only-text/html


# Netscape 4.06-4.08 have some more problems

BrowserMatch ^Mozilla/4\.0[678] no-gzip



# MSIE masquerades as Netscape, but it is fine

BrowserMatch \bMSIE !no-gzip !gzip-only-text/html



# Don't compress images and already compressed files

SetEnvIfNoCase Request_URI \\.(?:gif|jpg|cab|jpe?g|exe|bmp|rar|zip|swf|png)$ no-gzip dont-vary



# Make sure proxies don't deliver the wrong content, need load mod_headers.so

Header append Vary User-Agent env=!dont-vary





or if you want things simple(may bring some bugs on certain browsers):


DeflateCompressionLevel 7
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css

Friday, January 15, 2010

move your mouse automaticly :)

Access directory of JDK6/bin and run jrunscript.exe (note: only for JDK6)
Input scripts:
r = java.awt.Robot();
r.setAutoDelay(500);
while(true){r.mouseMove(500+100*Math.random(), 500+100*Math.random());}


share and enjoy it!

simple thread dump analysis Awk scripts

Here are the Thread.state we usually see and pay attention to:
* RUNNABLE
* BLOCKED
* WAITING
* TIMED_WAITING

If want to know what kind of status of thread dump i picked up from app server when CPU% is pretty high or want to find blocking threads, this is useful give you some insights, you can develop yours in 10 mins:)

BEGIN {RS="\n\"";IGNORECASE = 1;count1=0;count2=0;count3=0;count4=0;count5=0}

($0~ /workmanager\(/){

if ($0~ /State: runnable/) {

count1=count1+1;

}


if ($0~ /State: TIMED_WAITING on/){

count2=count2+1;

}

if ($0~ /State: WAITING\n/) {

count3=count3+1;

}

if ($0~ /State: WAITING on /) {

count4=count4+1;

}

if ($0~ /State: Blocked on /) {

count5=count5+1;

}


{

sum=sum+1;
}

}

END{
print "# of runnable threads is:" count1;
print "# of timed_Waiting on condition threads is: " count2;
print "# of Waiting threads is: " count3;
print "# of Waiting on condition threads is: " count4;
print "# of Blocked threads is: " count5;
print "Total num of threads: " sum;
}
-------------------
Sample output:

# of runnable threads is:10
# of timed_Waiting on condition threads is: 85
# of Waiting threads is: 0
# of Waiting on condition threads is: 3
# of Blocked threads is: 2
Total num of threads: 100


BTW, i found "timed_Waiting on" and "Blocked" threads number is huge, then you got problem on synchronization probably, dig into it.