[Wtr-general] Ideas on improving firewatir performance. Code included
Chintan Trivedi
chesschintan at gmail.com
Sat Apr 1 06:28:59 EST 2006
Hi,
FireWatir release was like "freedom of soul". I needed something like watir
to run on my linux system and firewatir solved that problem.
However, while working with firewatir, I found it to be very slow.
Initially it was tough to figure out as to what could be the problem. From
the code it seemed like there was lot of communication happening between
firewatir and jssh server. eg. Say for accessing a textbox, firewatir will
first ask the browser about the textbox element and then send the events.
Similarly for each and every element user requests for, will make firewatir
to talk with the browser. Keeping this in mind I created a sample code
which deals with this issue. Its available for download from
http://www.geocities.com/chesschintan/rufire.tgz The code first downloads
whole html page and uses htmltokenizer to create various textboxes, buttons
and other elements. This reduces a lot of overhead. Though it has one
drawback. That is if after opening a page using ff.goto(), the user manually
opens another page using firefox then the code would fail. However its a
kinda very rare case.
Second noticable thing was the way firewatir implemented read_socket().
This seemed to be a major cause decreasing the performance. However while
testing, jssh protocol was found to be kinda misbehaving. Simple socket.gets()
or socket.recv() doesnt work. May be thatz the reason which tempted author
to implement read_socket() in a reliable manner sacrificing bit of
performance. But socket.sysread() is a beautiful socket method which worked
for me.
After doing the above two changes code worked with charm even beating
(watir) IE performance. Rufire supports only textbox, radio, buttons and
checkbox elements. Its not a complete code. I made it just for the sake of
testing with above two changes. You can copy test.html available in the .tgz
to localhost webserver and test using test.rb file. Currently it lacks one
feature of knowing whether hml page has been loaded in browser or not. Add a
sleep statement with good value in Firefox.goto() just in case you wanna
test it against a heavy website.
Thanks
Chintan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060401/3711ec70/attachment.html
More information about the Wtr-general
mailing list