Re: [wtr-general] Re: Post form not on the page
On 15 August 2011 23:26, Dmitriy Korobskiy dkro...@gmail.com wrote: On 8/15/11 6:11 PM, Rahul Sharma wrote: I have tried it already but won't work as the form is not on the page. So browser won't know what form it is!! Two questions: 1. Why can't you drive the original application itself? (no local form) Reason for not being able to drive the application is that the form is not present on the application. It will be part of a clickable advert outside the application. If there are some serious reasons for not being able to do that, then 2. What happens exactly if you save this artificial form locally, then drive the browser to file:///my_local_form.html and do browser.form(:name, input).submit ? This should work I am pretty sure but the reason I do not want to save this form locally and tun my tests is that the tests run on Hudson build as well so I will have to maintain a copy on Hudson as well. Plus I will have to incorporate this local form in my project some where so that others can run this test on their machines as well. Also, the path, if the form is saved locally might be different on Hudson and local machine. All I have in my project is feature files and ruby files. Would it be alright to add html files in the project workspace? Is there any other way out? On 15 Aug 2011, at 20:57, orde wrote: Does this work (from http://rdoc.info/gems/watir/2.**0.1/Watir/Formhttp://rdoc.info/gems/watir/2.0.1/Watir/Form )? browser.form(:name, input).submit Hope it helps. orde On Aug 15, 7:48 am, Rahul Sharmarahulsharma@gmail.**comrahulsharma@gmail.com wrote: Hi Dimitry, The reason I wanted to submit a local form is that I can not simulate user clicks as part of the tests. The form in the question is: htmlhead meta http-equiv=content-type content=text/html; charset=ISO-8859-1 /headbodyform name=input action= test-environment-url/**promotion-code.promotion-**codecheck method=post promotions code:input name=promotions_code value=PromotionName type= text input value=Submit type=submit /form /body/html Mind the formatting. This is the source of the form I want to post. For some reason I can not click on the Submit button to post it in the test. Is there another way? On 12 August 2011 21:20, Dmitriy Korobskiydkro...@gmail.com wrote: On 8/6/11 1:33 PM, Rahul Sharma wrote: Thanks for the information there Dimitry and Chuck. I forgot to add one thing in my post. The form I am talking about is a form that has been created by a developer to assist automated testing. In real world, users of our website will see a promotion somewhere(let's say google). When one clicks on that advertisement it will bring the user to our website with the promotion code filled in and letting the users fill the rest of the form to be able to register and claim the promotion. So the form here is a HTML page written by a developer so that when I click on the button in the form it will do the same thing as in the real world when a customer clicks on a promotion on Google. I actually don;t have the HTML of the form handy but I can paste it on Monday when I get back to work. So basically my question was to whether I can define thatform /form in my Page and use it with the page object to post it and give me the website page filled with the promotion code just like the user would do actually. Rahul, Getting back to your original question of submitting a local form, why do you need to that? Do you really need to manipulate the form in a non-trivial way? If you don't, Watir can drive the browser to reproduce user clicks and filling the text on the form quite well without extra complications. -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please readhttp://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-generalhttp://groups.google.com/**group/watir-general http://**groups.google.com/group/watir-**generalhttp://groups.google.com/group/watir-general watir-general+unsubscribe@**go**oglegroups.comhttp://googlegroups.com watir-general%**2Bunsubscribe@go oglegroups.com -- Regards, Rahul Sharma Ph:+44 7800 736851 -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/**group/watir-generalhttp://groups.google.com/group/watir-general watir-general+unsubscribe@**googlegroups.comwatir-general%2bunsubscr...@googlegroups.com Regards, Rahul Sharma -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/**group/watir-generalhttp://groups.google.com/group/watir-general watir-general+unsubscribe@**googlegroups.comwatir-general%2bunsubscr...@googlegroups.com -- Regards, Rahul Sharma
Re: [wtr-general] Re: Post form not on the page
On 8/16/11 5:21 AM, Rahul Sharma wrote: On 15 August 2011 23:26, Dmitriy Korobskiy dkro...@gmail.com mailto:dkro...@gmail.com wrote: On 8/15/11 6:11 PM, Rahul Sharma wrote: I have tried it already but won't work as the form is not on the page. So browser won't know what form it is!! Two questions: 1. Why can't you drive the original application itself? (no local form) Reason for not being able to drive the application is that the form is not present on the application. It will be part of a clickable advert outside the application. Got it. It's a pretty solid reason. :) If there are some serious reasons for not being able to do that, then 2. What happens exactly if you save this artificial form locally, then drive the browser to file:///my_local_form.html and do browser.form(:name, input).submit ? This should work I am pretty sure but the reason I do not want to save this form locally and tun my tests is that the tests run on Hudson build as well so I will have to maintain a copy on Hudson as well. Plus I will have to incorporate this local form in my project some where so that others can run this test on their machines as well. Also, the path, if the form is saved locally might be different on Hudson and local machine. All I have in my project is feature files and ruby files. Would it be alright to add html files in the project workspace? Is there any other way out? All the obstacles you mentioned are solvable. You can put the local form somewhere along with the test-related files and get the absolute location in your test code, e.g. in Ruby: |File.dirname(|__FILE__) ||I would use a separate subdirectory for it. In the worst case you can pass the absolute location from Hudson as an environment variable (e.g. PROJECT_HOME=/somepath). -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: Post form not on the page
Hi Dimitry, The reason I wanted to submit a local form is that I can not simulate user clicks as part of the tests. The form in the question is: htmlhead meta http-equiv=content-type content=text/html; charset=ISO-8859-1 /headbodyform name=input action= test-environment-url/promotion-code.promotion-codecheck method=post promotions code: input name=promotions_code value=PromotionName type= text input value=Submit type=submit /form /body/html Mind the formatting. This is the source of the form I want to post. For some reason I can not click on the Submit button to post it in the test. Is there another way? On 12 August 2011 21:20, Dmitriy Korobskiy dkro...@gmail.com wrote: On 8/6/11 1:33 PM, Rahul Sharma wrote: Thanks for the information there Dimitry and Chuck. I forgot to add one thing in my post. The form I am talking about is a form that has been created by a developer to assist automated testing. In real world, users of our website will see a promotion somewhere(let's say google). When one clicks on that advertisement it will bring the user to our website with the promotion code filled in and letting the users fill the rest of the form to be able to register and claim the promotion. So the form here is a HTML page written by a developer so that when I click on the button in the form it will do the same thing as in the real world when a customer clicks on a promotion on Google. I actually don;t have the HTML of the form handy but I can paste it on Monday when I get back to work. So basically my question was to whether I can define thatform /form in my Page and use it with the page object to post it and give me the website page filled with the promotion code just like the user would do actually. Rahul, Getting back to your original question of submitting a local form, why do you need to that? Do you really need to manipulate the form in a non-trivial way? If you don't, Watir can drive the browser to reproduce user clicks and filling the text on the form quite well without extra complications. -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/**group/watir-generalhttp://groups.google.com/group/watir-general watir-general+unsubscribe@**googlegroups.comwatir-general%2bunsubscr...@googlegroups.com -- Regards, Rahul Sharma Ph:+44 7800 736851 -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
[wtr-general] Re: Post form not on the page
Does this work (from http://rdoc.info/gems/watir/2.0.1/Watir/Form)? browser.form(:name, input).submit Hope it helps. orde On Aug 15, 7:48 am, Rahul Sharma rahulsharma@gmail.com wrote: Hi Dimitry, The reason I wanted to submit a local form is that I can not simulate user clicks as part of the tests. The form in the question is: htmlhead meta http-equiv=content-type content=text/html; charset=ISO-8859-1 /headbodyform name=input action= test-environment-url/promotion-code.promotion-codecheck method=post promotions code: input name=promotions_code value=PromotionName type= text input value=Submit type=submit /form /body/html Mind the formatting. This is the source of the form I want to post. For some reason I can not click on the Submit button to post it in the test. Is there another way? On 12 August 2011 21:20, Dmitriy Korobskiy dkro...@gmail.com wrote: On 8/6/11 1:33 PM, Rahul Sharma wrote: Thanks for the information there Dimitry and Chuck. I forgot to add one thing in my post. The form I am talking about is a form that has been created by a developer to assist automated testing. In real world, users of our website will see a promotion somewhere(let's say google). When one clicks on that advertisement it will bring the user to our website with the promotion code filled in and letting the users fill the rest of the form to be able to register and claim the promotion. So the form here is a HTML page written by a developer so that when I click on the button in the form it will do the same thing as in the real world when a customer clicks on a promotion on Google. I actually don;t have the HTML of the form handy but I can paste it on Monday when I get back to work. So basically my question was to whether I can define thatform /form in my Page and use it with the page object to post it and give me the website page filled with the promotion code just like the user would do actually. Rahul, Getting back to your original question of submitting a local form, why do you need to that? Do you really need to manipulate the form in a non-trivial way? If you don't, Watir can drive the browser to reproduce user clicks and filling the text on the form quite well without extra complications. -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please readhttp://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/**group/watir-generalhttp://groups.google.com/group/watir-general watir-general+unsubscribe@**googlegroups.comwatir-general%2Bunsubscribe@go oglegroups.com -- Regards, Rahul Sharma Ph:+44 7800 736851 -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: Post form not on the page
On 8/15/11 3:57 PM, orde wrote: Does this work (from http://rdoc.info/gems/watir/2.0.1/Watir/Form)? browser.form(:name, input).submit Hope it helps. orde On Aug 15, 7:48 am, Rahul Sharmarahulsharma@gmail.com wrote: Hi Dimitry, The reason I wanted to submit a local form is that I can not simulate user clicks as part of the tests. The form in the question is: htmlhead meta http-equiv=content-type content=text/html; charset=ISO-8859-1 /headbodyform name=input action= test-environment-url/promotion-code.promotion-codecheck method=post promotions code:input name=promotions_code value=PromotionName type= text input value=Submit type=submit /form /body/html Mind the formatting. This is the source of the form I want to post. For some reason I can not click on the Submit button to post it in the test. Is there another way? Rahul, this looks quite simple and it should work. Try the orde's suggestion above. -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: Post form not on the page
I have tried it already but won't work as the form is not on the page. So browser won't know what form it is!! On 15 Aug 2011, at 20:57, orde wrote: Does this work (from http://rdoc.info/gems/watir/2.0.1/Watir/Form)? browser.form(:name, input).submit Hope it helps. orde On Aug 15, 7:48 am, Rahul Sharma rahulsharma@gmail.com wrote: Hi Dimitry, The reason I wanted to submit a local form is that I can not simulate user clicks as part of the tests. The form in the question is: htmlhead meta http-equiv=content-type content=text/html; charset=ISO-8859-1 /headbodyform name=input action= test-environment-url/promotion-code.promotion-codecheck method=post promotions code: input name=promotions_code value=PromotionName type= text input value=Submit type=submit /form /body/html Mind the formatting. This is the source of the form I want to post. For some reason I can not click on the Submit button to post it in the test. Is there another way? On 12 August 2011 21:20, Dmitriy Korobskiy dkro...@gmail.com wrote: On 8/6/11 1:33 PM, Rahul Sharma wrote: Thanks for the information there Dimitry and Chuck. I forgot to add one thing in my post. The form I am talking about is a form that has been created by a developer to assist automated testing. In real world, users of our website will see a promotion somewhere(let's say google). When one clicks on that advertisement it will bring the user to our website with the promotion code filled in and letting the users fill the rest of the form to be able to register and claim the promotion. So the form here is a HTML page written by a developer so that when I click on the button in the form it will do the same thing as in the real world when a customer clicks on a promotion on Google. I actually don;t have the HTML of the form handy but I can paste it on Monday when I get back to work. So basically my question was to whether I can define thatform /form in my Page and use it with the page object to post it and give me the website page filled with the promotion code just like the user would do actually. Rahul, Getting back to your original question of submitting a local form, why do you need to that? Do you really need to manipulate the form in a non-trivial way? If you don't, Watir can drive the browser to reproduce user clicks and filling the text on the form quite well without extra complications. -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please readhttp://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/**group/watir-generalhttp://groups.google.com/group/watir-general watir-general+unsubscribe@**googlegroups.comwatir-general%2Bunsubscribe@go oglegroups.com -- Regards, Rahul Sharma Ph:+44 7800 736851 -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com Regards, Rahul Sharma -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: Post form not on the page
On 8/15/11 6:11 PM, Rahul Sharma wrote: I have tried it already but won't work as the form is not on the page. So browser won't know what form it is!! Two questions: 1. Why can't you drive the original application itself? (no local form) If there are some serious reasons for not being able to do that, then 2. What happens exactly if you save this artificial form locally, then drive the browser to file:///my_local_form.html and do browser.form(:name, input).submit ? On 15 Aug 2011, at 20:57, orde wrote: Does this work (from http://rdoc.info/gems/watir/2.0.1/Watir/Form)? browser.form(:name, input).submit Hope it helps. orde On Aug 15, 7:48 am, Rahul Sharmarahulsharma@gmail.com wrote: Hi Dimitry, The reason I wanted to submit a local form is that I can not simulate user clicks as part of the tests. The form in the question is: htmlhead meta http-equiv=content-type content=text/html; charset=ISO-8859-1 /headbodyform name=input action= test-environment-url/promotion-code.promotion-codecheck method=post promotions code:input name=promotions_code value=PromotionName type= text input value=Submit type=submit /form /body/html Mind the formatting. This is the source of the form I want to post. For some reason I can not click on the Submit button to post it in the test. Is there another way? On 12 August 2011 21:20, Dmitriy Korobskiydkro...@gmail.com wrote: On 8/6/11 1:33 PM, Rahul Sharma wrote: Thanks for the information there Dimitry and Chuck. I forgot to add one thing in my post. The form I am talking about is a form that has been created by a developer to assist automated testing. In real world, users of our website will see a promotion somewhere(let's say google). When one clicks on that advertisement it will bring the user to our website with the promotion code filled in and letting the users fill the rest of the form to be able to register and claim the promotion. So the form here is a HTML page written by a developer so that when I click on the button in the form it will do the same thing as in the real world when a customer clicks on a promotion on Google. I actually don;t have the HTML of the form handy but I can paste it on Monday when I get back to work. So basically my question was to whether I can define thatform /form in my Page and use it with the page object to post it and give me the website page filled with the promotion code just like the user would do actually. Rahul, Getting back to your original question of submitting a local form, why do you need to that? Do you really need to manipulate the form in a non-trivial way? If you don't, Watir can drive the browser to reproduce user clicks and filling the text on the form quite well without extra complications. -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please readhttp://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/**group/watir-generalhttp://groups.google.com/group/watir-general watir-general+unsubscribe@**googlegroups.comwatir-general%2Bunsubscribe@go oglegroups.com -- Regards, Rahul Sharma Ph:+44 7800 736851 -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com Regards, Rahul Sharma -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: Post form not on the page
On 8/6/11 1:33 PM, Rahul Sharma wrote: Thanks for the information there Dimitry and Chuck. I forgot to add one thing in my post. The form I am talking about is a form that has been created by a developer to assist automated testing. In real world, users of our website will see a promotion somewhere(let's say google). When one clicks on that advertisement it will bring the user to our website with the promotion code filled in and letting the users fill the rest of the form to be able to register and claim the promotion. So the form here is a HTML page written by a developer so that when I click on the button in the form it will do the same thing as in the real world when a customer clicks on a promotion on Google. I actually don;t have the HTML of the form handy but I can paste it on Monday when I get back to work. So basically my question was to whether I can define thatform /form in my Page and use it with the page object to post it and give me the website page filled with the promotion code just like the user would do actually. Rahul, Getting back to your original question of submitting a local form, why do you need to that? Do you really need to manipulate the form in a non-trivial way? If you don't, Watir can drive the browser to reproduce user clicks and filling the text on the form quite well without extra complications. -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
[wtr-general] Re: Post form not on the page
Be aware that doing stuff like this with forms at the HTTP level can get very tricky. You generally must first establish a session with the webserver, then capture specific data regarding the session, and potentially other things like 'viewstate' and be able to include them along with the form data in your response. Using a value from earlier won't work as that session will usually have expired, you almost always have to capture and extract the stuff you need on the fly. (you'll get really good at regular expressions, trust me) Technically, this is close to 'spoofing' and thus there are many security measures (like viewstate) that are designed to prevent spoofing that will trip you up unless you do it exactly right. This kind of stuff requires either a pretty in-depth knowledge of HTTP and how webservers maintain state and sessions, or a good tool that will do a lot of things for you. (the 'webtest' tools built into the latest version of visual studio (if you are .net folks) is actually pretty good at doing stuff like this at the protocol level, especially if your site is done in .net. ) On Aug 5, 12:40 pm, Dmitriy Korobskiy dkro...@gmail.com wrote: On 8/5/11 6:04 AM, Rahul Sharma wrote: I have already tried Net::HTTP.post_form but I guess it only works for forms that are on some page. Rahul, when a form is posted, the POST data in the request body contains only pairs of HTTP-encoded form fields: NAME=VALUE That *might* be all you need. It does not matter much where the original page is located keeping in mind the following two caveats: 1. Your target page might or might not be checking HTTP_REFERRER value in the request's HTTP headers. HTTP_REFERRER contains the URL of the original page, and it should be easy to put it in when you assemble your request manually in your code. 2. Your browser session typically contains session and maybe even persistent cookies that keep track of (logged in) user session and get submitted with each request. If you capture cookies, you can put them into your request. I hope it helps. -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: Post form not on the page
Thanks for the information there Dimitry and Chuck. I forgot to add one thing in my post. The form I am talking about is a form that has been created by a developer to assist automated testing. In real world, users of our website will see a promotion somewhere(let's say google). When one clicks on that advertisement it will bring the user to our website with the promotion code filled in and letting the users fill the rest of the form to be able to register and claim the promotion. So the form here is a HTML page written by a developer so that when I click on the button in the form it will do the same thing as in the real world when a customer clicks on a promotion on Google. I actually don;t have the HTML of the form handy but I can paste it on Monday when I get back to work. So basically my question was to whether I can define that form /form in my Page and use it with the page object to post it and give me the website page filled with the promotion code just like the user would do actually. On 6 Aug 2011, at 12:17, Chuck van der Linden wrote: Be aware that doing stuff like this with forms at the HTTP level can get very tricky. You generally must first establish a session with the webserver, then capture specific data regarding the session, and potentially other things like 'viewstate' and be able to include them along with the form data in your response. Using a value from earlier won't work as that session will usually have expired, you almost always have to capture and extract the stuff you need on the fly. (you'll get really good at regular expressions, trust me) Technically, this is close to 'spoofing' and thus there are many security measures (like viewstate) that are designed to prevent spoofing that will trip you up unless you do it exactly right. This kind of stuff requires either a pretty in-depth knowledge of HTTP and how webservers maintain state and sessions, or a good tool that will do a lot of things for you. (the 'webtest' tools built into the latest version of visual studio (if you are .net folks) is actually pretty good at doing stuff like this at the protocol level, especially if your site is done in .net. ) On Aug 5, 12:40 pm, Dmitriy Korobskiy dkro...@gmail.com wrote: On 8/5/11 6:04 AM, Rahul Sharma wrote: I have already tried Net::HTTP.post_form but I guess it only works for forms that are on some page. Rahul, when a form is posted, the POST data in the request body contains only pairs of HTTP-encoded form fields: NAME=VALUE That *might* be all you need. It does not matter much where the original page is located keeping in mind the following two caveats: 1. Your target page might or might not be checking HTTP_REFERRER value in the request's HTTP headers. HTTP_REFERRER contains the URL of the original page, and it should be easy to put it in when you assemble your request manually in your code. 2. Your browser session typically contains session and maybe even persistent cookies that keep track of (logged in) user session and get submitted with each request. If you capture cookies, you can put them into your request. I hope it helps. -- DK AIM: DKroot1, Skype: DKroot -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com Regards, Rahul Sharma -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com