Sunday, March 16, 2008

Using Selenium for testing

This summary is not available. Please click here to view the post.

Saturday, March 15, 2008

GetHtmlSource() acting differently in different locations of the app - II

Well...was able to get around this issue - by recording the script again!!?? Strange as it may sound, but yes, thats all I did - recorded the same steps again and this time both gethtmlsource and getbodytext gave proper output!

-V.

Wednesday, March 12, 2008

Post - Read Timeout Error - VI

Small victory!
Though havent figured out reasion for the exception, but was able to get around the issue by running Selenium server in 'multiWindow' mode instead of 'proxyInjection' mode that I had been running it in!
Yee! :)

-V.

Tuesday, March 11, 2008

Post - Read Timeout Error V

Phew - small progress - realised that if I close ALL other IE windows when I am executing the script, the Read Timeout doesnt occur - not atleast at the location where it always used to before! Though, it still did bomb out few steps later. Will have to R&D that now...
But hey, a little progress! :)

-V.

Saturday, March 8, 2008

Select_window_ok("mainframe")

Everytime a popup window closes, to get back to the main window, Selenium executes a selectWindow method with argument = mainframe. This works fine in Selenium IDE rerun on firefox, but almost always fails in Selenium RC with perl script with the following message -

# ERROR: could not find window mainFrame
# Failed test 'select_window, mainFrame'
# at pa_sa_item_dis_PO_40.pl line 102.

Review of Selenium document on select_window() reveals the following -
"...
1.) if windowID is null, (or the string "null") then it is assumed the user is referring to the original window instantiated by the browser).
..."


Making the simple change to the method from select_window_ok("mainframe") to select_window_ok() did the trick!

-V.

Select_frame("relative=???)

Selenium IDE records a frame change as a selectframe|relative=up||. Now, this works perfectly if I am re-running the script from IDE in firefox. But if I export the same script in Perl and then try running in IE or Firefox (in proxyInjection mode), I get stuck at the point when the method 'select_frame_ok("relative=up") is called.
I look thru the Selenium document and came across this -
"...
To select the parent frame, use"relative=parent" as a locator; to select the top frame, use "relative=top".
..."

No mention of 'relative=up'...I decided to give 'parent' a try - select_Frame_ok("relative=parent") and script did move forward without any issue this time around... :)

-V.

Get_window_id() cant be used to retrieve windowID of the current window

Ever since I have started testing using Selenium, I have had this issue where the waitforpagetoload() results in a 'timed out waiting for window "" to appear' error. This incidently doesnt happen on all waitforpagetoload() methods in the script.
So, I figured, if I could some how find the window_id of the window being looked for, I can look more deeper into why that window is not 'appearing'. I added a get_window_id() method to the script to retrieve that id, but turns out, it cant be used in such scenarios.
As per this post in the Selenium forum, there are other ways the method can be used - but those apply to pop-up windows...There arent any window.open method for the current window and I think this is the reason, the get_window_id() method returns no value for current window...
Too bad...

-V.

Friday, March 7, 2008

GetHtmlSource() acting differently in different locations of the app

I have a perl subroutine that i add to the exported selenium script to validate if there is a certain message (message1) appearing upon performing certain steps in the app.
I have the subroutine in testscript1.pl (for module1 in AUT) and in testscript2.pl (for module2 in AUT).
Testscript1.pl executes with the html source of the AUT being spit out, but testscript2.pl gives a modified html code as pasted below...


Subroutine added in both Scripts -
"
...
sub data_extract
{
my $text=0;
$text = $sel->get_html_source_ok();
print "$text\n";
if ($text =~ m/$_[0]/){
print "there is a validation error on page\n";
$sel->select_frame_ok("topframe");
$sel->click_ok("link=Logout");
$sel->stop;
exit; }
}
...
...
...
&data_extract("Validation Error");
...

Expecting - to see the html source of the AUT.
Actually see - the html content referencing selenium scripts all over.

Issue that its causing - in testscript1.pl, I am able to logout upon a 'Validation Error', but in testscript2.pl, I am not. I tried with get_body_text() too, but same result.

This is how I start selenium rc -
C:\selenium\selenium-remote-control-0.9.2\selenium-server-0.9.2>java -jar selenium-server.jar -inter
active -Dselenium.slowMode=500 -log selenium_perl.log -proxyInjectionMode



Have posted this issue in the Selenium Forum - lets see if someone can figure the issue out.

-V.

Saturday, March 1, 2008

POST - Read Timeout error - IV

Some Googling on the exception and found this Sun Developer Network link.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5043147

It says that the issue is closed and fixed..?

-V.

POST - Read Timeout error - III

Not a very happy thing happened!
The POST - Read time out error occured on the HTTP side of the app as well - though exception is little different... -

Now, will have to look at this issue from a different point of view...

###############################
17:21:52.424 INFO - Command request: click[finishButton, ] on session 919230
17:21:53.033 INFO - Got result: OK on session 919230
17:21:53.049 INFO - Command request: waitForPageToLoad[30000, ] on session 919230
17:22:55.342 WARN - POST http://10.1.50.41:7034/selenium-server/driver/?closing=true&localFrameAddre
ss=top&seleniumWindowName=choiceWindow&uniqueId=sel_48283&sessionId=919230&counterToMakeURsUniqueAnd
SoStopPageCachingInTheBrowser=1204410114268&sequenceNumber=1 HTTP/1.0
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at org.mortbay.util.LineInput.fill(LineInput.java:477)
at org.mortbay.util.LineInput.read(LineInput.java:352)
at java.io.FilterInputStream.read(Unknown Source)
at org.mortbay.http.HttpInputStream.read(HttpInputStream.java:120)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at sun.nio.cs.StreamDecoder.read0(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.readPostedData(SeleniumDriverRes
ourceHandler.java:251)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleBrowserResponse(SeleniumDr
iverResourceHandler.java:169)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHan
dler.java:125)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.http.HttpServer.service(HttpServer.java:909)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
17:24:53.099 INFO - Command request: selectWindow[, ] on session 919230
17:24:54.005 WARN - GET /selenium-server/driver/?cmd=waitForPageToLoad&1=30000&sessionId=919230 HTTP
/1.1
java.lang.RuntimeException: unexpected browser error from getTitle: ERROR: got a null result
##########################


-V.