Friday, February 29, 2008

POST - Read Timeout error - II

Executed the script on the app in non-SSL mode (HTTP and not HTTPS), and the script executes without issue. So looks like issue is due to the fact that the page is a secure page...hmm.

-V.

POST - Read Timeout error

I have been getting this exception all too often lately, and I am not sure if the root cause is due to the site under test being a HTTPS, or is it due to other 'caching' reasons.

At some points, the scripts continue to execute even after this exception, but most of the time, it just freezes and then after the timeout period testComplete[, ] is executed.

Line of script that causes this exception is -

"
...
$sel->click_ok("btnAddToCart");
$sel->wait_for_page_to_load_ok("10000");
$sel->click_ok("finishButton");
$sel->wait_for_page_to_load_ok("10000");
$sel->select_window_ok();
$sel->click_ok("document.caPurchasingAssistantWizardForm.submitbutton[1]");
$sel->wait_for_page_to_load_ok("10000");
$sel->click_ok("//input[\@value='Apply Discount...']");
...
"



###########################3
12:56:16.333 INFO - Command request: click[submitbutton, ] on session 589192
12:56:16.958 INFO - Got result: OK on session 589192
12:56:17.020 INFO - Command request: waitForPageToLoad[15000, ] on session 589192
12:56:29.765 WARN - POST https://mytestsiteURL.com:443/selenium-server/driver/?seleniu
mWindowName=choiceWindow&counterToMakeURsUniqueAndSoStopPageCachingInTheBrowser=1204307778707&sessio
nId=589192&localFrameAddress=top&sequenceNumber=1&closing=true&uniqueId=sel%5F16463 HTTP/1.0
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.AppInputStream.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)


12:59:17.008 INFO - Command request: selectWindow[, ] on session 589192
12:59:17.554 WARN - GET /selenium-server/driver/?cmd=waitForPageToLoad&1=15000&sessionId=589192 HTTP
/1.1
java.lang.RuntimeException: unexpected browser error from getTitle: ERROR: got a null result
at org.openqa.selenium.server.FrameGroupCommandQueueSet.getRemoteWindowTitle(FrameGroupComma
ndQueueSet.java:439)
at org.openqa.selenium.server.FrameGroupCommandQueueSet.matchesFrameAddress(FrameGroupComman
dQueueSet.java:548)
at org.openqa.selenium.server.FrameGroupCommandQueueSet.findMatchingFrameAddress(FrameGroupC
ommandQueueSet.java:511)
at org.openqa.selenium.server.FrameGroupCommandQueueSet.waitForLoad(FrameGroupCommandQueueSe
t.java:482)
at org.openqa.selenium.server.FrameGroupCommandQueueSet.waitForLoad(FrameGroupCommandQueueSe
t.java:450)
at org.openqa.selenium.server.FrameGroupCommandQueueSet.waitForLoad(FrameGroupCommandQueueSe
t.java:465)
at org.openqa.selenium.server.FrameGroupCommandQueueSet.doCommand(FrameGroupCommandQueueSet.
java:292)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResource
Handler.java:478)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDri
verResourceHandler.java:375)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHan
dler.java:123)
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)


-V

Gracefully exiting on a validation error on page

There are often times when there is a validation error on the page and the buttons expected oinideal scenario dont appear. In such cases, the script continues to execute though - expecting the elements in future lines of the script to be present, when they are actually not since the application has stopped due to the Validation error.

At times, this causes an issue too, coz the script ends up 'clicking' an element that it should not have (for eg. a submit button that should have been clicked upon the scenario being successful will still get clicked even though the expected result wasnt encountered - leading to different flow being executed).

So to avoid such things from happening, I wrote up a simple subroutine that I added at the start of the script which would "get_body_text()" and then verify that a text 'validation error' was not present anywhere on the page. If found, exit. No more steps to be executed.

##########################
sub data_extract
{
my $text=0;
$text = $sel->get_body_text();
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;
}
}
##########################

-V

Thursday, February 28, 2008

Purpose of this Blog

Not going to spend too much time nor too many lines explaining the purpose!
I am creating this to document issues / resolutions / tricks / processes that I have used to go about using Perl, lest I forget about them in future.
I should have started this last year itself, but better late than never! I will try to recall and add older info from time to time.

-V