Why not do it as a scenario outline, Then in the examples specify two or more filenames that point to files of known size that allow you to explore the boundaries
You could for readability even include the size of the files in the feature, but just ignore it other than paying attention to it when creating the test data. It's harder for me to be specific without seeing your UI, but I'd be thinking of somethign along these lines As the site administrator I want to limit users to uploading avatar image files of size 50K or less to keep the size of avatars reasonable and keep the db space used by BLOB's under control. Scenario Outline Given I am logged in as a normal user and I am on the user profile upload avatar page When I select logo file <filename> for uploading as my avatar Then I should <warningstatus> that the file is too large And the uploadbutton should be <buttonstatus> Examples |filename|size|warningstatus|buttonstatus| |logo1|48K|not see a warning|enabled| |logo2|49.99K|not see a warning|enabled| |logo3|50K|not see a warning|enabled| |logo4|50.001K|be given a warning|disabled| |logo5|51K|be given a warning|disabled| |logo6|500K|be given a warning|disabled| |logo7|500M|be given a warning|disabled| I have not tried this, but I think it should work. if you had to actually pass in the size, to not have an error in the feature, then you could just ignore it in the step. Alternatively you could just use filenames that make the intent clear.. 'logotest_49_99K', which might be even simpler and I wish it had occured to me before I finished composing the example above :-) On Dec 19, 10:40 am, Irfan Ahmed <[email protected]> wrote: > Hi, Jarmo Pertman, > Thanks for your response. Actually there was a problem to find out a file > size for upload. Becuase, I need to know if the file size is more then > "something" then the system will display a message "xcvbnnm". Look at the > step generated by cucumber: > *Given /^I have selected a logo "([^"]*)" of size (\d+) MB$/ do |arg1, arg2| > * > * browser.file_field(:name, "file").set(arg1)* > *end* > * > this step will be passed if size of image file arg2 is the size equal to > arg1. > > the file there I set (**browser.file_field(:name, "file").set(arg1)) too > upload a picture, I need to write a code to show that the file has a size of > minimum requirement and so that I need to findout the size of that. So here > I need to know how know a size of a picture or any file which are taken to > upload. > * > > > > > > On Sun, Dec 19, 2010 at 6:24 PM, Jarmo Pertman <[email protected]> wrote: > > I didn't understand what's the exact problem. Could you be more > > specific what you'd want to exactly do? > > > Jarmo Pertman > > ----- > > IT does really matter -http://www.itreallymatters.net > > > On Dec 19, 5:02 am, Irfan Ahmed <[email protected]> wrote: > > > Hi, > > > I am working for automation with Cucumber and watir in a software > > company. > > > I have a problem while working windows component for uploading I need to > > do > > > the following: > > > > *Given /^I have selected a logo "([^"]*)" of size (\d+) MB$/ do |arg1, > > arg2| > > > * > > > * browser.file_field(:name, "file").set(arg1)* > > > *end* > > > * > > > * > > > But, I am having problem to get to the file size to pass this test. I > > need > > > to compare the file size with the given size. > > > > Anybody, please help me as soon as possible. > > > > -- > > > Thanks, > > > Irfan Ahmed Rizvi (Sagar) > > > > cell Numbers: > > > +880 1676 246 991 > > > +880 1723 712 888 > > > > Tasawr Interactive <http://www.tasawr.com> > > > -- > > Before posting, please readhttp://watir.com/support. In short: search > > before you ask, be nice. > > > [email protected] > >http://groups.google.com/group/watir-general > > [email protected]<http://groups.google.com/group/watir-general%0Awatir-general+unsubscr...> > > -- > Thanks, > Irfan Ahmed Rizvi (Sagar) > > cell Numbers: > +880 1676 246 991 > +880 1723 712 888 > > http://www.welltreat.ushttp://restaurant.welltreat.us/http://isp.welltreat.us/- > Hide quoted text - > > - Show quoted text - -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected]
