So a 'clickAndWait' in IDE is actually exported as click() and then waitForPageToLoad(). In some instance, it actually causes an expection when run in RC with the message - [timed out waiting for window '']. It simply drives me crazy when this happens for no reason!!
Anyway, some looking and found this opinion in the google gp - http://groups.google.com/group/selenium-users/browse_thread/thread/219a4a94bae46f7a/a1e810086507b733?lnk=gst&q=waitforpagetoload#a1e810086507b733
So, now if I have a click that is not actually loading a new page, but is just refreshing something on the same page, I remove the waitForPageToLoad command completely. Has had some success, though I havent tested it thoroughly in different scenarios yet.
Another thing I did - I use the -Dselenium.slowMode=2000 option to start Selenium RC. I increased it from 1000 to 2000. Hopefully that is also making the difference as now the commands are executing slower.
Monday, April 19, 2010
waitForPageToLoad() - Hate It!!!!
Friday, April 9, 2010
Starting Selenium RC
Selenium can be started with different options.
One of them is -multiWindow
I cant remember where I found this option and for what purpose I had included it in my startup, so to find out its purpose, I removed it to see what affect it has.
Removing that option has one change - previously the selenium test frame and the AUT frame would open as 2 different tabs in IE. Now, after removing the -multiWindow option, AUT runs in the same frame and I dont see the selenium test frame.
C:
cd C:\selenium-remote-control-1.0-beta-2\selenium-server-1.0-beta-2
java -jar selenium-server.jar -interactive -proxyInjectionMode -Dselenium.slowMode=1000
@REM -multiWindow
Update:
So -multiWindow was an option used prior to rel 1.0 of Selenium to load the AUT in full browser, instead of loading it in a lower frame.
Since 1.0, this is the default behavior of Selenium, so there is no need to specify that option explicitly.
I have Selenium 1.0 beta installed and I think my using -multiWindow was actually negating the default -multiWindow and hence loading AUT in lower frame.
Mystery solved!!
Tuesday, May 5, 2009
Perl Client for Selenium Install
Ok, so finally I got Selenium with Perl to work again!! And this time I am going to jot down the steps.
1. Install Perl
2. Download Selenium Perl "CLIENT" from Luke Cross, located here - http://search.cpan.org/~lukec/Test-WWW-Selenium-1.13
3. Unzip the download and follow the instructions in readme file.
"
To install:
perl Makefile.PL
make
make test
make install
"
Note: Instead of 'make' use 'nmake' on windows machine.
4. Now is the tricky part - selenium.pm is available in multiple places and we have to be careful to be using the right one. File located at C:\Installs\Selenium\Test-WWW-Selenium-1.13\Test-WWW-Selenium-1.13\lib\Test\WWW is a 7kb file that is different from the 65kb file located at C:\Installs\Selenium\Test-WWW-Selenium-1.13\Test-WWW-Selenium-1.13\lib\WWW. Make sure to be using/pointing to the 7kb file and you are good to go!
More info on how to use the Perl Client driver is available at -
http://seleniumhq.org/documentation/remote-control/languages/perl.html
-V
Sunday, April 26, 2009
Compilation Error
Error -
D:\Selenium\PerlTestCases>perl Test-userverify.pl
Can't locate Test/LongString.pm in @INC (@INC contains: C:\Perl\lib C:\Perl\site\lib C:/Perl/site/lib C:/Perl/lib .) at C:\Perl\site\lib/Test/WWW/Selenium.pm line 56.
BEGIN failed--compilation aborted at C:\Perl\site\lib/Test/WWW/Selenium.pm line 56.
Compilation failed in require at Test-userverify.pl line 4.
BEGIN failed--compilation aborted at Test-userverify.pl line 4.
Analysis:
http://aspn.activestate.com/ASPN/Mail/Message/perl-unix-users/2010251
========================
> The following is the error i getback.=============================================
>
> perl test.pl
> Can't locate XML/Simple.pm in @INC (@INC contains:
> /usr/local/lib/perl5/5.00503/sun4-solaris-thread
> /usr/local/lib/perl5/5.00503
> /usr/local/lib/perl5/site_perl/5.005/sun4-solaris-thread
> /usr/local/lib/perl5/site_perl/5.005 .) at test.pl line 1.
> BEGIN failed--compilation aborted at test.pl line 1.
>
>
> Questions :
> 1. Can the xml parser libraries be used in the above version of perl
> itself. At the code level itsel without any config or env. changes that
> need root access - as if root access is needed it becomes a long winding
> process as this is a prod. box.
> 2. If i can't use the above xml Can i locally install within the userid
> scope i am working on.
It looks like you are just having the typical problem of the perl binary not
the XML module in it's @INC path. You might want to check in
/usr/local/lib/perl5 and /usr/local/lib/perl5/site_perl for any other
versions of perl installed, or a 'where perl' or 'which perl', to see if
there are any other perl binaries installed. Perhaps there is another
perl installation on the system that has the XML module.
If the system does not have the XML module installed and you do not have
root access to install the module, you can install the module in the
same directory as your script, though you'll have to create the
directories by hand and do the installation manually. You'd have to
download and compile/build the XML module, then create the necessary
directories and place the appropriate files there. For example:
ls -l:
XML/Simple.pm
XML.pm
Something like that.
This post has some info on the issue. I do have 2 vsn of perl installed - one came with the Oracle install, and 2nd (latest) is the one I installed manually. I dont want to mess with the oracle install...so I just updated the Path env variable - although it din have any effect...
Next I tried to install/compile the package missing locally(LongString). I copied the LongString.pm file to the expected folder.
Above error went away, but another one popup up. That will be discussed in future post..
-V.
Complition error - when Selenium WWW not installed
D:\Selenium\PerlTestCases>perl Test-userverify.pl
Can't locate Test/WWW/Selenium.pm in @INC (@INC contains: C:\Perl\lib C:\Perl\site\lib C:/Perl/site/
lib C:/Perl/lib .) at Test-userverify.pl line 4.
BEGIN failed--compilation aborted at Test-userverify.pl line 4.
Resolution:
Downloaded "WWW::Selenium - Perl driver for the Selenium testing framework" from http://search.cpan.org/~MBARBON/Test-WWW-Selenium-0.03/lib/WWW/Selenium.pm
Following build/install instructions.
Tuesday, April 29, 2008
proxy.pac
I had done something with proxy.pac file sometime back to make things work with IE...and I cant remember now what it was. And I am pretty sure thats the reason why my scripts are not executing now...should have documented that earlier! This is what happens if one gets lazy. :)
Will post back once I figure out how to get it back up.
-V.
Sunday, March 16, 2008
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.
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