Thread: [Http-webtest-general] on_response question
Brought to you by:
m_ilya,
richardanderson
From: Remo B. <fo...@we...> - 2003-03-31 20:57:43
|
hi @all sorry for my possibly stupid question i have the follow test case --------- test_name = 'login with as admin (EN)' url = http://localhost/app/login.pl click_button = Login params = ( uid => admin passwd => foobar doit => login lang => EN ) #-- get sessionID on_response = { my $webtest = shift; ($SID) = $webtest->current_response()->headers->{refresh}; $SID =~ s/.*sessionID=([\d\w]+).*/$1/; []; } end_test test_name = 'logout admin (EN)' url = http://localhost/app/menu.pl params = ( tab => logout lang => EN sessionID => $SID ) end_test --------- why that does not do ? $SID isn't set ;((( note: - yes, i read all pod documents and the cookbook - yes, the regex for sessionID works my $SID = '0; URL=/app/menu.pl?sessionID=2eff4f3df913d371508aa03f2a390a77'; $SID =~ s/.*sessionID=([\d\w]+).*/$1/; print "$SID\n"; $> 2eff4f3df913d371508aa03f2a390a77 - yes, i use the latest version of module from cpan - yes, i use perl 5.8 ;))) thx for help cu -- RayMan <fo...@we...> |
From: Ilya M. <il...@ip...> - 2003-04-01 10:36:12
|
>>>>> "RB" == Remo Behn <fo...@we...> writes: RB> hi @all RB> sorry for my possibly stupid question RB> i have the follow test case RB> --------- RB> test_name = 'login with as admin (EN)' RB> url = http://localhost/app/login.pl RB> click_button = Login RB> params = ( RB> uid => admin RB> passwd => foobar RB> doit => login RB> lang => EN RB> ) RB> #-- get sessionID RB> on_response = { RB> my $webtest = shift; RB> ($SID) = $webtest->current_response()->headers->{refresh}; RB> $SID =~ s/.*sessionID=([\d\w]+).*/$1/; RB> []; RB> } RB> end_test RB> [..snip..] RB> why that does not do ? RB> $SID isn't set ;((( RB> [..snip..] $webtest->current_response->headers Returns HTTP::Headers object which has other API then you are using. Instead of $webtest->current_response->headers->{refresh} you should write $webtest->current_response->headers->header('refresh'); See perldoc HTTP::Headers for details. Moreover HTTP::Request object ($webtest->current_response) have some shortcuts to access headers. You can rewrite code above to $webtest->current_response->header('refresh'); See perldoc HTTP::Message for details (this is a base class of HTTP::Request) -- Ilya Martynov, il...@ip... CTO IPonWEB (UK) Ltd Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net Personal website - http://martynov.org |
From: Gerry F. <ga...@cs...> - 2003-04-01 11:34:49
|
Illa, Being kinda new to this stuff, I have a follow up question. Isn't it also necessary for the second case to contain an anonymous function as well, so $SID is evaluated at runtime, rather than at load? e.g. sessionID => $SID should really be sessionID => sub { $SID } Gerry On Tue, 01 Apr 2003 14:36:05 +0400 Ilya Martynov <il...@ip...> wrote: > >>>>> "RB" == Remo Behn <fo...@we...> writes: > > RB> hi @all > > RB> sorry for my possibly stupid question > > RB> i have the follow test case > > RB> --------- > RB> test_name = 'login with as admin (EN)' > RB> url = http://localhost/app/login.pl > RB> click_button = Login > RB> params = ( > RB> uid => admin > RB> passwd => foobar > RB> doit => login > RB> lang => EN > RB> ) > RB> #-- get sessionID > RB> on_response = { > RB> my $webtest = shift; > RB> ($SID) = > RB> $webtest->current_response()->headers->{refresh};$SID > RB> =~ s/.*sessionID=([\d\w]+).*/$1/; > RB> []; > RB> } > RB> end_test > > RB> [..snip..] > > RB> why that does not do ? > RB> $SID isn't set ;((( > > RB> [..snip..] > > $webtest->current_response->headers > > Returns HTTP::Headers object which has other API then you are using. > > Instead of > > $webtest->current_response->headers->{refresh} > > you should write > > $webtest->current_response->headers->header('refresh'); > > See perldoc HTTP::Headers for details. > > Moreover HTTP::Request object ($webtest->current_response) have some > shortcuts to access headers. You can rewrite code above to > > $webtest->current_response->header('refresh'); > > See perldoc HTTP::Message for details (this is a base class of > HTTP::Request) > > > -- > Ilya Martynov, il...@ip... > CTO IPonWEB (UK) Ltd > Quality Perl Programming and Unix Support > UK managed @ offshore prices - http://www.iponweb.net > Personal website - http://martynov.org > > > ------------------------------------------------------- > This SF.net email is sponsored by: ValueWeb: > Dedicated Hosting for just $79/mo with 500 GB of bandwidth! > No other company gives more support or power for your dedicated server > http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ > _______________________________________________ > Http-webtest-general mailing list > Htt...@li... > https://lists.sourceforge.net/lists/listinfo/http-webtest-general -- Gerry Finkel phone (732)302-0222 ext. 6614 ga...@cs... fax (732)302-0799 MQSS pager (800) 759-8888 pin 1909963 As often happens, once we had a few songs finished that we liked, the newer ones started to get weirder. Daring grows out of confidence (or what the ancient Greeks called "hubris," I guess). Neil Peart |
From: Ilya M. <il...@ip...> - 2003-04-01 11:53:48
|
>>>>> "GF" == Gerry Finkel <ga...@cs...> writes: GF> Illa, GF> Being kinda new to this stuff, I have a follow up question. Isn't it GF> also necessary for the second case to contain an anonymous function as GF> well, so $SID is evaluated at runtime, rather than at load? GF> e.g. GF> sessionID => $SID GF> should really be GF> sessionID => sub { $SID } Actually sessionID => $SID is not evaluated at all. It is equalent to sessionID => '$SID' To be evaluated it should be written as sessionID => "$SID" As for evaluation time it is always evaluted in runtime and concerning HTTP::WebTest internals it is exactly equalent to sessionID => sub { "$SID" } -- Ilya Martynov, il...@ip... CTO IPonWEB (UK) Ltd Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net Personal website - http://martynov.org |
From: Ilya M. <il...@ip...> - 2003-04-01 12:53:23
|
>>>>> "IM" == Ilya Martynov <il...@ip...> writes: IM> To be evaluated it should be written as IM> sessionID => "$SID" IM> As for evaluation time it is always evaluted in runtime and concerning IM> HTTP::WebTest internals it is exactly equalent to IM> sessionID => sub { "$SID" } Sorry, I meant it is exactly equalent to sessionID => { "$SID" } Gerry, I think you confused wtscript format here with Perl code. Original poster had his test defined as wtscript. -- Ilya Martynov, il...@ip... CTO IPonWEB (UK) Ltd Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net Personal website - http://martynov.org |
From: Gerry F. <ga...@cs...> - 2003-04-01 14:11:55
|
Illa, Yup - you're right. I pretty much only write perl scripts for my tests, not wtscript. Thanks for the clarification. Gerry On Tue, 01 Apr 2003 16:53:16 +0400 Ilya Martynov <il...@ip...> wrote: > >>>>> "IM" == Ilya Martynov <il...@ip...> writes: > > IM> To be evaluated it should be written as > > IM> sessionID => "$SID" > > IM> As for evaluation time it is always evaluted in runtime and > IM> concerning HTTP::WebTest internals it is exactly equalent to > > IM> sessionID => sub { "$SID" } > > Sorry, > > I meant it is exactly equalent to > > sessionID => { "$SID" } > > > Gerry, I think you confused wtscript format here with Perl code. > Original poster had his test defined as wtscript. > > -- > Ilya Martynov, il...@ip... > CTO IPonWEB (UK) Ltd > Quality Perl Programming and Unix Support > UK managed @ offshore prices - http://www.iponweb.net > Personal website - http://martynov.org > > > ------------------------------------------------------- > This SF.net email is sponsored by: ValueWeb: > Dedicated Hosting for just $79/mo with 500 GB of bandwidth! > No other company gives more support or power for your dedicated server > http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ > _______________________________________________ > Http-webtest-general mailing list > Htt...@li... > https://lists.sourceforge.net/lists/listinfo/http-webtest-general -- Gerry Finkel phone (732)302-0222 ext. 6614 ga...@cs... fax (732)302-0799 MQSS pager (800) 759-8888 pin 1909963 As often happens, once we had a few songs finished that we liked, the newer ones started to get weirder. Daring grows out of confidence (or what the ancient Greeks called "hubris," I guess). Neil Peart |
From: Remo B. <fo...@we...> - 2003-04-01 18:24:46
Attachments:
login_cyrus.wt
a.txt
|
On Tue, 01 Apr 2003 14:36:05 +0400 Ilya Martynov <il...@ip...> wrote: > >>>>> "RB" == Remo Behn <fo...@we...> writes: [...] > $webtest->current_response->headers > > Returns HTTP::Headers object which has other API then you are using. > Instead of > $webtest->current_response->headers->{refresh} > you should write > $webtest->current_response->headers->header('refresh'); > See perldoc HTTP::Headers for details. > Moreover HTTP::Request object ($webtest->current_response) have some > shortcuts to access headers. You can rewrite code above to > $webtest->current_response->header('refresh'); > See perldoc HTTP::Message for details (this is a base class of > HTTP::Request) sorry, don't work, i am stupid ??? i'm not understand the concept ;( i have attach my *.wt and an Data::Dumper output cu -- RayMan <fo...@we...> |
From: Ilya M. <il...@ip...> - 2003-04-02 12:56:59
|
>>>>> "RB" == Remo Behn <fo...@we...> writes: RB> On Tue, 01 Apr 2003 14:36:05 +0400 RB> Ilya Martynov <il...@ip...> wrote: >> >>>>> "RB" == Remo Behn <fo...@we...> writes: RB> [...] RB> sorry, don't work, i am stupid ??? RB> i'm not understand the concept ;( RB> i have attach my *.wt and an Data::Dumper output RB> cu RB> -- RB> RayMan <fo...@we...> RB> ignore_case = no RB> mail = no RB> mail_addresses = ( foobar@localhost ) RB> mail_server = localhost RB> method = POST RB> [ ... cut other tests ... ] RB> test_name = 'login with as cyrus (EN)' RB> url = http://localhost/app/login.pl RB> params = ( RB> uid => cyrus RB> passwd => cyrus RB> doit => login RB> lang => EN RB> ) RB> #-- get sessionID RB> on_response = { RB> my $webtest = shift; RB> ($SID) = $webtest->current_response->header('refresh'); RB> $SID =~ s/.*sessionID=([\d\w]+).*/$1/; RB> []; RB> } RB> end_test RB> test_name = 'logout cyrus (EN)' RB> url = http://localhost/app/menu.pl?sessionID=$SID You'll have to take put this parameters in double quotes or it will not expand value of $SID I.e. url = "http://localhost/app/menu.pl?sessionID=$SID" RB> params = ( RB> tab => logout RB> lang => EN RB> sessionID => $SID Same problem here. Should be sessionID => "$SID" RB> ) RB> end_test -- Ilya Martynov, il...@ip... CTO IPonWEB (UK) Ltd Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net Personal website - http://martynov.org |
From: Remo B. <fo...@we...> - 2003-04-02 18:28:09
|
On Tue, 01 Apr 2003 15:53:40 +0400 Ilya Martynov <il...@ip...> wrote: > >>>>> "GF" == Gerry Finkel <ga...@cs...> writes: [...] > To be evaluated it should be written as > > sessionID => "$SID" don't work ... unfortunately $SID is empty ??? ok, drop all *.wt files and make my testcases direct in the perlscript, than i have no problem ;))) [...] thx for your help ... cu -- RayMan <fo...@we...> |
From: Gerry F. <ga...@cs...> - 2003-04-03 14:47:07
|
All, I'm writing perl code (vs wt scripts) for my tests. I'm trying to build a series of perl objects to allow cleaner development, but now I'm starting to question how this really works. I'm hoping someone can tell me if this is a bad idea. I have a base class called TestCase. Extended from that is a class for a specific page/servlet that I'm interacting with. I seem to be corrupting some data (specifically my URL) after several gets/posts are sent to the servlet. Below is several chunks of code which I hope will explain what I'm doing. There's a comment in the leftmost column where I see the problem. Each of my classes have genFunc() methods for generating arrays of URLs which generate the queries I need. I do things like my $numlist = Csf::ListMgmt->new(); $webtest->run_tests($numlist->genGetWholeList($listid)); to generate my test runs. I guess my main question is, is it safe to reference $self inside on_request? And can I say things like $self->anotherMethod() inside on_request? Is this just a bad thing to do? Hope it's clear from my example what I'm doing. Gerry package Csf::ListMgmt; use strict; sub genGetWholeList { my $self = shift; my $listid = shift; return ( { test_name => 'Number List Get Whole List', method => 'get', url => $self->{baseUrl} . 'path', params => { obj => sub { $self->{artData}->{screenObj} }, op => 'whole', opval => $listid }, text_require => [ '<title>Number List Administration</title>', '<textarea rows="10" name="numbers"', '<input type="checkbox" name="saveList"', ], text_forbid => [ ], on_response => sub { my $webtest = shift; my @results = (); push(@results, $self->checkForErrors($webtest)); my @list = $self->getNumbersForList($webtest); # It's at this point that my URL seems to be corrupt. $self->{artData}->{numbersInList} = \@list; # This piece of code puts all numbers in this number # list into the results for "USER DEFINED TESTS" in # the report. # #foreach my $num (@list) { # push(@results, 'yes', $num); #} push(@results, $self->showScreenObject()); return \@results; }, -- Gerry Finkel phone (732)302-0222 ext. 6614 ga...@cs... fax (732)302-0799 MQSS pager (800) 759-8888 pin 1909963 As often happens, once we had a few songs finished that we liked, the newer ones started to get weirder. Daring grows out of confidence (or what the ancient Greeks called "hubris," I guess). Neil Peart |
From: Ilya M. <il...@ma...> - 2003-04-03 20:08:24
|
>>>>> On Thu, 3 Apr 2003 09:46:41 -0500, Gerry Finkel <ga...@cs...> said: GF> All, GF> [..snip..] GF> I have a base class called TestCase. Extended from that is a class for a GF> specific page/servlet that I'm interacting with. I seem to be corrupting GF> some data (specifically my URL) after several gets/posts are sent to the GF> servlet. GF> Below is several chunks of code which I hope will explain what I'm GF> doing. There's a comment in the leftmost column where I see the problem. GF> Each of my classes have genFunc() methods for generating arrays of URLs GF> which generate the queries I need. I do things like GF> my $numlist = Csf::ListMgmt->new(); GF> $webtest->run_tests($numlist->genGetWholeList($listid)); GF> to generate my test runs. GF> I guess my main question is, is it safe to reference $self inside GF> on_request? And can I say things like $self->anotherMethod() inside GF> on_request? Is this just a bad thing to do? There is nothing wrong with it. You have a closure and unless Perl has a bug it should work just as you expect it to work: i.e when HTTP::WebTest calls it you get your Csf::ListMgmt object inside of your on_request handler and you should be able to call its methods. Can you elaborate 'I seem to be corrupting some data ...' please? Do you mean that HTTP::WebTest's objects change unexpectedly or do you mean that Csf::ListMgmt object changes unexpectedly? BTW it is hard to tell for sure without seeing all code but should not be it easier to rewrite your testing code as a plugin instead of using on_request hooks? GF> [..snip..] -- Ilya Martynov, il...@ip... CTO IPonWEB (UK) Ltd Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net Personal website - http://martynov.org |
From: Gerry F. <ga...@cs...> - 2003-04-14 12:03:06
|
Illya, Sorry I haven't responded - I got sidetracked for a week. I think it's good enough for me to know that this should be working; I assume I just have a bug in my code. I'd rather not waste your time trying to debug my code (although if you're interested, I'm quite willing to mail it all to you). I hadn't looked into plugins yet. Perhaps that's the way I should be going, since the more time I spend at this, the more code I write in the on_response hook. I guess that's where I'll head now... Thanks for your help. Gerry On Fri, 04 Apr 2003 00:05:24 +0400 Ilya Martynov <il...@ma...> wrote: > >>>>> On Thu, 3 Apr 2003 09:46:41 -0500, Gerry Finkel > ><ga...@cs...> said: > > GF> All, > GF> [..snip..] > > GF> I have a base class called TestCase. Extended from that is a class > GF> for a specific page/servlet that I'm interacting with. I seem to > GF> be corrupting some data (specifically my URL) after several > GF> gets/posts are sent to the servlet. > > GF> Below is several chunks of code which I hope will explain what I'm > GF> doing. There's a comment in the leftmost column where I see the > GF> problem. Each of my classes have genFunc() methods for generating > GF> arrays of URLs which generate the queries I need. I do things like > > GF> my $numlist = Csf::ListMgmt->new(); > GF> $webtest->run_tests($numlist->genGetWholeList($listid)); > > GF> to generate my test runs. > > GF> I guess my main question is, is it safe to reference $self inside > GF> on_request? And can I say things like $self->anotherMethod() > GF> inside on_request? Is this just a bad thing to do? > > There is nothing wrong with it. You have a closure and unless Perl has > a bug it should work just as you expect it to work: i.e when > HTTP::WebTest calls it you get your Csf::ListMgmt object inside of > your on_request handler and you should be able to call its methods. > > Can you elaborate 'I seem to be corrupting some data ...' please? Do > you mean that HTTP::WebTest's objects change unexpectedly or do you > mean that Csf::ListMgmt object changes unexpectedly? > > BTW it is hard to tell for sure without seeing all code but should not > be it easier to rewrite your testing code as a plugin instead of using > on_request hooks? > > GF> [..snip..] > > -- > Ilya Martynov, il...@ip... > CTO IPonWEB (UK) Ltd > Quality Perl Programming and Unix Support > UK managed @ offshore prices - http://www.iponweb.net > Personal website - http://martynov.org > > > > ------------------------------------------------------- > This SF.net email is sponsored by: ValueWeb: > Dedicated Hosting for just $79/mo with 500 GB of bandwidth! > No other company gives more support or power for your dedicated server > http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ > _______________________________________________ > Http-webtest-general mailing list > Htt...@li... > https://lists.sourceforge.net/lists/listinfo/http-webtest-general -- Gerry Finkel phone (732)302-0222 ext. 6614 ga...@cs... fax (732)302-0799 MQSS pager (800) 759-8888 pin 1909963 As often happens, once we had a few songs finished that we liked, the newer ones started to get weirder. Daring grows out of confidence (or what the ancient Greeks called "hubris," I guess). Neil Peart |
From: Ilya M. <il...@ip...> - 2003-04-14 13:22:05
|
>>>>> "GF" == Gerry Finkel <ga...@cs...> writes: GF> Illya, GF> Sorry I haven't responded - I got sidetracked for a week. GF> I think it's good enough for me to know that this should be working; I GF> assume I just have a bug in my code. I'd rather not waste your time GF> trying to debug my code (although if you're interested, I'm quite GF> willing to mail it all to you). I'm curious, so, yes, please send it me. Though I don't promise anything :) GF> I hadn't looked into plugins yet. Perhaps that's the way I should be GF> going, since the more time I spend at this, the more code I write in the GF> on_response hook. I guess that's where I'll head now... Too much code in on_response hooks is definetely bad smell and moving it in plugins is definetely better idea. The reason is simple: plugins are ordinary Perl modules so it is easier to reuse and test this code. -- Ilya Martynov, il...@ip... CTO IPonWEB (UK) Ltd Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net Personal website - http://martynov.org |