**Murder by Cucumber** . . . cannot submit form!

I just spent a lot of time learning the Webdriver.io API in order to test a form containing a table with cells with different types of fields (checkbox, button, dropdown, etc.) . The last task was to submit the form . . . and WHAM ! Zero success!

The failure is completely silent. It is as though the click(), or the submit() or the submitForm() command was never issued.

#####HTML

<form id="posts_form" class="form-horizontal">
           ; 
           ; 
        <div class="buttons">
            <button id="btnSave" type="submit" class="btn btn-primary">
               Generate
            </button>        
        </div>
    </div>
</form>

#####Javascript

Template.my_form.events = {
  'click #btnSave': function(e, t) {
    e.preventDefault();
    var checkboxes = $('.checkAll');
        :  
        :

Can anyone tell me the correct way, or point out an example of how, to submit a form when using Webdriver.io in Cucumber in Velocity in Meteor?

Thanks.

Hey. Can you please post the content of your feature file and the step defs too

It’s better to use 'submit #posts_form' in your event map.

1 Like

Yes @Sam. I am getting to that. Sorry. (I accidentally posted the question before I was really finished asking it.)

@deb – good tip! In fact that may be the answer, (if one is in control of the system under test).

@deb Ok! Yup! That was exactly the solution in my case. I’d be curious to know the solution if one has no access to the source code of the SUT, but not enough to pursue it right now?

I really appreciate your help with that. I was looking at other possible causes entirely.

Good to hear you got it sorted.

Could you please try the latest 0.6.0-rc.7 release? It’s a complete rewrite and should be more stable. Would love the feedback.

@sam Yes, of course! Delighted.

I’ll do it right away.

@sam

It screws up magnificently :smile:

TypeError: Cannot read property 'browser' of undefined
  at World.<anonymous> (/home/yourself/projects/golden_meteoris/tests/cucumber/features/lib/hooks.js:24:12)

My hooks.js file looks like this :

(function () {

  'use strict';

  module.exports = function () {

    var helper = this;

    this.Before(function () {
      var world = helper.world;
      var next = arguments[arguments.length - 1];
      world.browser.
        init().
        setViewportSize({
          width: 1280,
          height: 1024
        }).
        call(next);
    });

    this.After(function () {
      var world = helper.world;
      var next = arguments[arguments.length - 1];
      world.browser.
        end().
        call(next);
    });

  };

})();

My “tests” dir looks like this :

.
└── cucumber
    ├── features
    │   ├── lib
    │   │   ├── hooks.js
    │   │   └── world.js
    │   ├── mugen_jobs
    │   │   └── mugen_jobs_steps.js
    │   └── mugen_jobs.feature
    └── fixture.js

My feature looks like this :

Feature: Create a new master collection

  As a developer I need to be able to create the CRUDSS operations for a master collection
  I want to specify its name and the fields specifications of the collection
  So that I have a fully manageable new collection, ready to associate with a slave collection

  Scenario:
    Given I am on the CRUDSS generator page
    When I name my new collection "jobs"
    And I add the table :
      | Name   |  Type  | Required | Label | isOf |  FK  |
      | title  | String | required | Title | null | null |
      | posted | Date   | required | Date  | null | null |
    And I generate the new collection
    Then I can open the "jobs" manager's index page

But, I see that all the stuff about “hooks” and “world” is now obsolete, correct?

@sam

By the way . . . I am playing with Meteoris and its CRUD generator. I have added a tests directory and have got the first part of the user guide automated with Cucumber.

I’ll post a pull request when I have adapted my work to date to your new version.

You can safely remove your hook.js file and also the world.js file (if you’re not doing anything special in there that is.

In your tests, you can now use this.browser instead of helper.world.browser

Great to hear about Meteoris

@sam

Another glitch :

  this.browser
    .submitForm(xpathCRUDSSForm)
    .alertAccept();

Gets me :

RuntimeError: RuntimeError
     Problem: Invalid Command Method - {"headers":{"Accept":"application/json","Connection":"keep-alive","User-Agent":"webdriverio/webdriverio/2.4.5","content-  etc., etc., etc.,

 Callstack:
 -> alertAccept()

Any ideas? or do you need deeper details?

Difficult to see what’s going on from the snip. Maybe if you can create a simple repro I could try to look