webdrivercss icon indicating copy to clipboard operation
webdrivercss copied to clipboard

Incorrect 2 test Mocha Example?

Open micahgodbolt opened this issue 8 years ago • 5 comments

I'm new to Mocha, so bare with me, but in trying to set up multiple webdrivercss tests inside of a mocha test I followed the example in the readme file

// Example using Mocha
it('should check the first page',function(done) {
  client
    .init()
    .url('https://example.com')
    // Make this name unique.
    .webdrivercss('page1', [
      {
        name: 'test',
        screenWidth: [320,480,640,1024]
      }, {
        name: 'test_two',
        screenWidth: [444,666]
      }
    ])
    .end()
    .call(done);
});

it('should check the second page',function(done) {
  client
    // ...
    // Make this name unique.
    .webdrivercss('page2', [
      // ..
    ])
    // ...
);

I continued to get the following errors on the second "should check the second page" test.

Uncaught RuntimeError
     (UnknownError:13) An unknown server-side error occurred while processing the command.
     Problem: POST /session//url

I was able to resolve the issue by removing the .end() function from the first test.

Is this the correct way to run tests? Does .end() tell webdriver to stop? Should we update the documentation?

micahgodbolt avatar Sep 03 '15 14:09 micahgodbolt

As a side note, is there any way we can improve the error message when this happens?

TheSavior avatar Sep 03 '15 16:09 TheSavior

@micahgodbolt the end() should happen in a after() function so it won't close the connection. (unless if it's a single test you are running).

In a "shoovified" example you can see there's no end() inside the it()

amitaibu avatar Sep 03 '15 16:09 amitaibu

As a side note, is there any way we can improve the error message when this happens?

The (cryptic) error message is coming from here

amitaibu avatar Sep 03 '15 16:09 amitaibu

@amitaibu @TheSavior we used to check if a command requires a session id but this seems to not work anymore. I created an issue to tackle this

christian-bromann avatar Sep 03 '15 18:09 christian-bromann

@micahgodbolt you didn't get a session ID so somehow the init function wasn't executed or at least not executed successfully

christian-bromann avatar Sep 03 '15 18:09 christian-bromann