Thread: [Http-webtest-general] Using Click and Hooks
Brought to you by:
m_ilya,
richardanderson
From: William M. <wi...@kn...> - 2002-07-31 02:11:10
|
Greetings, Well, I've discovered the wonders of the click_button test parameter lately. That's a nice feature. A question: is it possible to tell HTTP::WebTest which form to use when clicking the button. I have a page with several forms that have a button with the same name. I can work around it but was curious. I have also begun to use the on_reponse hook to grab dynamic data from the tests. I saw in the Cookbook under the "User-Defined Tests" section an example that reads from the database. The example uses a dbh in $Test::dbh. However, I didn't see how this value ever got set. Can someone provide some details? Do I set it up in the webtest script or in the perl script I use to begin the tests? Thanks, William -- Lead Developer Knowmad Services Inc. || Internet Applications & Database Integration http://www.knowmad.com |
From: Ilya M. <il...@ma...> - 2002-07-31 08:21:39
|
>>>>> On Tue, 30 Jul 2002 22:12:59 -0400, "William McKee" <wi...@kn...> said: MC> Greetings, Hi William, MC> Well, I've discovered the wonders of the click_button test MC> parameter lately. That's a nice feature. A question: is it MC> possible to tell HTTP::WebTest which form to use when clicking the MC> button. I have a page with several forms that have a button with MC> the same name. I can work around it but was curious. It is impossible right now. On the other hand it is not very hard to add ability to tell HTTP::WebTest which form to use. I just not sure about interface. How do you want to specify form to use? Form number on page? Form name (given that you set it with name attribute)? MC> I have also begun to use the on_reponse hook to grab dynamic data MC> from the tests. I saw in the Cookbook under the "User-Defined MC> Tests" section an example that reads from the database. The MC> example uses a dbh in $Test::dbh. However, I didn't see how this MC> value ever got set. Can someone provide some details? Do I set it MC> up in the webtest script or in the perl script I use to begin the MC> tests? You can either set it in the perl script or in on_request/on_response hooks in first test block. I have plans to add additional hooks to be run at the begining and at the end of test sequence. -- Ilya Martynov (http://martynov.org/) |
From: William M. <wi...@kn...> - 2002-07-31 11:46:05
|
On 31 Jul 2002 at 12:20, Ilya Martynov wrote: > It is impossible right now. On the other hand it is not very hard to > add ability to tell HTTP::WebTest which form to use. I just not sure > about interface. How do you want to specify form to use? Form number > on page? Form name (given that you set it with name attribute)? I generally give my forms names when I have multiple forms on a page. So this would be the format that I'd prefer. Can you show me an example of how I would tell WebTest which form to use? > You can either set it in the perl script or in on_request/on_response > hooks in first test block. I have plans to add additional hooks to be > run at the begining and at the end of test sequence. The create/destroy hooks sound like just the thing for the dbh situation. In the meantime, I was hoping to see an example of setting the dbh in a test block. When I pickup a cookbook, I expect complete recipes <g>. Unless I missed it, the recipe for querying a database is incomplete because it does not explain where the Test object came from. Thanks, William -- Lead Developer Knowmad Services Inc. || Internet Applications & Database Integration http://www.knowmad.com |
From: Ilya M. <il...@ma...> - 2002-07-31 14:30:51
|
>>>>> On Wed, 31 Jul 2002 07:47:57 -0400, "William McKee" <wi...@kn...> said: WM> On 31 Jul 2002 at 12:20, Ilya Martynov wrote: >> It is impossible right now. On the other hand it is not very hard to >> add ability to tell HTTP::WebTest which form to use. I just not sure >> about interface. How do you want to specify form to use? Form number >> on page? Form name (given that you set it with name attribute)? WM> I generally give my forms names when I have multiple forms on a WM> page. So this would be the format that I'd prefer. Can you show me WM> an example of how I would tell WebTest which form to use? I'm not sure yet. Maybe another test parameter like form_name. >> You can either set it in the perl script or in >> on_request/on_response hooks in first test block. I have plans to >> add additional hooks to be run at the begining and at the end of >> test sequence. WM> The create/destroy hooks sound like just the thing for the dbh WM> situation. In the meantime, I was hoping to see an example of WM> setting the dbh in a test block. When I pickup a cookbook, I WM> expect complete recipes <g>. Unless I missed it, the recipe for WM> querying a database is incomplete because it does not explain WM> where the Test object came from. There is not Test object. It just a variable in namespace of Test package. If you run HTTP::WebTest from script you could initialize it with $Test::dbh = DBI->connect(...); Actually you can use any namespace for variables you pass from Perl script to wtscript. Anyway you are right that this recipt is incomplete. I should rework it and explain initialization. P.S. BTW if you find yourself writing too much Perl code in wtscript files you should consider writting you own plugins and moving your Perl code into them. It is not very hard - look in sources of any of default plugins in lib/HTTP/WebTest/Plugin. -- Ilya Martynov (http://martynov.org/) |
From: William M. <wi...@kn...> - 2002-07-31 15:10:20
|
On 31 Jul 2002 at 18:24, Ilya Martynov wrote: > I'm not sure yet. Maybe another test parameter like form_name. Oh, I thought you meant it is possible to do this now. You meant it's easy to add the ability. Yes, a parameter like form_name seems fine. > There is not Test object. It just a variable in namespace of Test > package. If you run HTTP::WebTest from script you could initialize it > with > > $Test::dbh = DBI->connect(...); > > Actually you can use any namespace for variables you pass from Perl > script to wtscript. Ok, I see. I'll try that and let you know how it works. > P.S. BTW if you find yourself writing too much Perl code in wtscript > files you should consider writting you own plugins and moving your > Perl code into them. It is not very hard - look in sources of any of > default plugins in lib/HTTP/WebTest/Plugin. It sounds like the interface to DBI is a potential candidate for a plugin! I'm not sure how it would be initialized in order to get the connection string, though. Thanks, William -- Lead Developer Knowmad Services Inc. || Internet Applications & Database Integration http://www.knowmad.com |
From: Ilya M. <il...@ma...> - 2002-07-31 15:16:06
|
>>>>> On Wed, 31 Jul 2002 11:11:54 -0400, "William McKee" <wi...@kn...> said: WM> It sounds like the interface to DBI is a potential candidate for a WM> plugin! I'm not sure how it would be initialized in order to get WM> the connection string, though. You can define your own test parameters in plugin to specify connection string. Read perldoc HTTP::WebTest::Plugins and look in sources of existing. It should not be hard. -- Ilya Martynov (http://martynov.org/) |