Mikel Lindsaar
2008-Nov-18 10:12 UTC
[rspec-users] Cucumber - how to spec a quick search box
Hello all. Wondering if anyone else has solved this. Some websites (including the intranet app I am working on) have a form in the top corner of the site that is buttonless. If you focus on this form enter text and hit enter, it submits. usually used for quick search boxes. Question, has anyone managed to tie that into a cucumber feature? Scenario: Using the quick search box Given I am logged in And I visit the home page And there is someone called ''Bob Smith'' to search for When I put ''Bob Smith'' into the quick search box And I hit enter Then I should be shown the search results page And there should be ''Bob Smith'' on the page it''s the ''And I hit enter'' that is bugging me :) Any ideas? Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog.... -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081118/4bf609ac/attachment.html>
Mikel Lindsaar wrote:> Hello all. > > Wondering if anyone else has solved this. > > Some websites (including the intranet app I am working on) have a form > in the top corner of the site that is buttonless. If you focus on this > form enter text and hit enter, it submits. usually used for quick > search boxes. > > Question, has anyone managed to tie that into a cucumber feature? > > Scenario: Using the quick search box > Given I am logged in > And I visit the home page > And there is someone called ''Bob Smith'' to search for > When I put ''Bob Smith'' into the quick search box > And I hit enter > Then I should be shown the search results page > And there should be ''Bob Smith'' on the page > > it''s the ''And I hit enter'' that is bugging me :) > > Any ideas? >I''ve encountered the same problem. I generally try and pull the abstraction up a bit a say something like: When I submit a quick search for ''Bob Smith'' But here I''m assuming that its not really important to the customer how they submit the form just that they can. WDYT? -- Joseph Wilk http://blog.josephwilk.net
On Tue, Nov 18, 2008 at 5:44 AM, Joseph Wilk <josephwilk at joesniff.co.uk> wrote:> Mikel Lindsaar wrote: >> >> Hello all. >> >> Wondering if anyone else has solved this. >> >> Some websites (including the intranet app I am working on) have a form in >> the top corner of the site that is buttonless. If you focus on this form >> enter text and hit enter, it submits. usually used for quick search boxes. >> >> Question, has anyone managed to tie that into a cucumber feature? >> >> Scenario: Using the quick search box >> Given I am logged in >> And I visit the home page >> And there is someone called ''Bob Smith'' to search for >> When I put ''Bob Smith'' into the quick search box >> And I hit enter >> Then I should be shown the search results page >> And there should be ''Bob Smith'' on the page >> >> it''s the ''And I hit enter'' that is bugging me :) >> >> Any ideas? >> > I''ve encountered the same problem. I generally try and pull the abstraction > up a bit a say something like: > > When I submit a quick search for ''Bob Smith'' > > But here I''m assuming that its not really important to the customer how they > submit the form just that they can. > > WDYT?I agree with Matt. Unless it was really really really important to the customer how the thing was submitted I wouldn''t try to automate the pressing of the enter button in the browser. I would more or less just say what I was doing rather than how I was doing it. I might end up with: Given I''m a logged in user at the home page And there is someone called ''Bob Smith'' to earch for When I do a quick search for ''Bob Smith'' Then I should see that ''Bob Smith'' is found in the search results If you''re wondering how you submit the quick search (since it has no button) then here''s a suggestion that Ben Mabey gave me back in September: use <noscript> tags to have a button on the page that Webrat can submit, but that the browser won''t render. Here''s a link to that comment: http://www.nabble.com/Re%3A-webrat-question%2C-form-without-buttons-p19299723.html -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com
Zach Dennis wrote:> On Tue, Nov 18, 2008 at 5:44 AM, Joseph Wilk <josephwilk at joesniff.co.uk> wrote: > >> Mikel Lindsaar wrote: >> >>> Hello all. >>> >>> Wondering if anyone else has solved this. >>> >>> Some websites (including the intranet app I am working on) have a form in >>> the top corner of the site that is buttonless. If you focus on this form >>> enter text and hit enter, it submits. usually used for quick search boxes. >>> >>> Question, has anyone managed to tie that into a cucumber feature? >>> >>> Scenario: Using the quick search box >>> Given I am logged in >>> And I visit the home page >>> And there is someone called ''Bob Smith'' to search for >>> When I put ''Bob Smith'' into the quick search box >>> And I hit enter >>> Then I should be shown the search results page >>> And there should be ''Bob Smith'' on the page >>> >>> it''s the ''And I hit enter'' that is bugging me :) >>> >>> Any ideas? >>> >>> >> I''ve encountered the same problem. I generally try and pull the abstraction >> up a bit a say something like: >> >> When I submit a quick search for ''Bob Smith'' >> >> But here I''m assuming that its not really important to the customer how they >> submit the form just that they can. >> >> WDYT? >> > > I agree with Matt. Unless it was really really really important to the > customer how the thing was submitted I wouldn''t try to automate the > pressing of the enter button in the browser. I would more or less > just say what I was doing rather than how I was doing it. I might end > up with: > > Given I''m a logged in user at the home page > And there is someone called ''Bob Smith'' to earch for > When I do a quick search for ''Bob Smith'' > Then I should see that ''Bob Smith'' is found in the search results > > If you''re wondering how you submit the quick search (since it has no > button) then here''s a suggestion that Ben Mabey gave me back in > September: use <noscript> tags to have a button on the page that > Webrat can submit, but that the browser won''t render. > > Here''s a link to that comment: > http://www.nabble.com/Re%3A-webrat-question%2C-form-without-buttons-p19299723.html > > >And if you are using Selenium: key_press :search, 13 -- Joseph Wilk http://blog.josephwilk.net
Bryan Helmkamp
2008-Nov-19 02:32 UTC
[rspec-users] Cucumber - how to spec a quick search box
If the form tag has an ID, you can use Webrat'' new submit_form method to do just this sort of thing. -Bryan On Tue, Nov 18, 2008 at 8:36 AM, Joseph Wilk <josephwilk at joesniff.co.uk> wrote:> Zach Dennis wrote: >> >> On Tue, Nov 18, 2008 at 5:44 AM, Joseph Wilk <josephwilk at joesniff.co.uk> >> wrote: >> >>> >>> Mikel Lindsaar wrote: >>> >>>> >>>> Hello all. >>>> >>>> Wondering if anyone else has solved this. >>>> >>>> Some websites (including the intranet app I am working on) have a form >>>> in >>>> the top corner of the site that is buttonless. If you focus on this form >>>> enter text and hit enter, it submits. usually used for quick search >>>> boxes. >>>> >>>> Question, has anyone managed to tie that into a cucumber feature? >>>> >>>> Scenario: Using the quick search box >>>> Given I am logged in >>>> And I visit the home page >>>> And there is someone called ''Bob Smith'' to search for >>>> When I put ''Bob Smith'' into the quick search box >>>> And I hit enter >>>> Then I should be shown the search results page >>>> And there should be ''Bob Smith'' on the page >>>> >>>> it''s the ''And I hit enter'' that is bugging me :) >>>> >>>> Any ideas? >>>> >>>> >>> >>> I''ve encountered the same problem. I generally try and pull the >>> abstraction >>> up a bit a say something like: >>> >>> When I submit a quick search for ''Bob Smith'' >>> >>> But here I''m assuming that its not really important to the customer how >>> they >>> submit the form just that they can. >>> >>> WDYT? >>> >> >> I agree with Matt. Unless it was really really really important to the >> customer how the thing was submitted I wouldn''t try to automate the >> pressing of the enter button in the browser. I would more or less >> just say what I was doing rather than how I was doing it. I might end >> up with: >> >> Given I''m a logged in user at the home page >> And there is someone called ''Bob Smith'' to earch for >> When I do a quick search for ''Bob Smith'' >> Then I should see that ''Bob Smith'' is found in the search results >> >> If you''re wondering how you submit the quick search (since it has no >> button) then here''s a suggestion that Ben Mabey gave me back in >> September: use <noscript> tags to have a button on the page that >> Webrat can submit, but that the browser won''t render. >> >> Here''s a link to that comment: >> >> http://www.nabble.com/Re%3A-webrat-question%2C-form-without-buttons-p19299723.html >> >> >> > > And if you are using Selenium: > > key_press :search, 13 > > -- > Joseph Wilk > http://blog.josephwilk.net > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- Bryan Helmkamp http://brynary.com -- My blog
Mikel Lindsaar
2008-Nov-19 14:56 UTC
[rspec-users] Cucumber - how to spec a quick search box
On Wed, Nov 19, 2008 at 1:32 PM, Bryan Helmkamp <lists at brynary.com> wrote:> If the form tag has an ID, you can use Webrat'' new submit_form method > to do just this sort of thing. >Not wrong about being new :) 24 hours ago... recent enough not to be in the History.txt file and I had to go hunting for the change set ;) Thanks, works perfectly! Mikel -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081120/b46f229c/attachment.html>