Add ability to query for console messages and errors #201

Merged
merged 3 commits into from Dec 7, 2011

Conversation

Projects
None yet
9 participants
@joefiorini
Contributor

joefiorini commented Oct 31, 2011

  • This changes the format of console message output to use "|" as the
    delimiter instead of ":"; ":" is no good for splitting when there are
    URLs and error messages in the output
  • WebPage tracks all console messages and clears them out on reset
@joefiorini

This comment has been minimized.

Show comment Hide comment
@joefiorini

joefiorini Oct 31, 2011

Contributor

Also added a matcher to be able to say:

page.should_not have_errors
Contributor

joefiorini commented Oct 31, 2011

Also added a matcher to be able to say:

page.should_not have_errors
@mike-burns

This comment has been minimized.

Show comment Hide comment
@mike-burns

mike-burns Oct 31, 2011

Owner

A tab character seems more canonical than a pipe.

Owner

mike-burns commented Oct 31, 2011

A tab character seems more canonical than a pipe.

@joefiorini

This comment has been minimized.

Show comment Hide comment
@joefiorini

joefiorini Oct 31, 2011

Contributor

All console messages are printed to the screen in raw format (with delimiters). Wouldn't using tabs would make this harder to read? I'm happy to change it something more canonical, but I'd prefer to use a printed character for that reason.

Contributor

joefiorini commented Oct 31, 2011

All console messages are printed to the screen in raw format (with delimiters). Wouldn't using tabs would make this harder to read? I'm happy to change it something more canonical, but I'd prefer to use a printed character for that reason.

@seanami

This comment has been minimized.

Show comment Hide comment
@seanami

seanami Nov 1, 2011

Awesome. Excited to use page.should_not have_errors in my tests.

seanami commented Nov 1, 2011

Awesome. Excited to use page.should_not have_errors in my tests.

@joefiorini

This comment has been minimized.

Show comment Hide comment
@joefiorini

joefiorini Nov 11, 2011

Contributor

Is there something I can do to help move this along?

Contributor

joefiorini commented Nov 11, 2011

Is there something I can do to help move this along?

@morenocarullo

This comment has been minimized.

Show comment Hide comment
@morenocarullo

morenocarullo Nov 11, 2011

Contributor

+1 this pull request would be very useful.

Contributor

morenocarullo commented Nov 11, 2011

+1 this pull request would be very useful.

@jferris

This comment has been minimized.

Show comment Hide comment
@jferris

jferris Nov 15, 2011

Owner

Thanks for putting this together. I'll try to have a look at this soon.

Owner

jferris commented Nov 15, 2011

Thanks for putting this together. I'll try to have a look at this soon.

joefiorini added some commits Oct 31, 2011

Add ability to query for console messages & errors
- This changes the format of console message output to use "|" as the
delimiter instead of ":"; ":" is no good for splitting when there are
URLs and error messages in the output
- WebPage tracks all console messages and clears them out on reset
@joefiorini

This comment has been minimized.

Show comment Hide comment
@joefiorini

joefiorini Dec 6, 2011

Contributor

It's been almost a month-and-a-half since I submitted this. I'm working on a screencast and would like to use this feature in it, but I don't want to point people to my personal fork. Are there problems with this I can fix or there anything else I can do to help get this through? Thanks!

Contributor

joefiorini commented Dec 6, 2011

It's been almost a month-and-a-half since I submitted this. I'm working on a screencast and would like to use this feature in it, but I don't want to point people to my personal fork. Are there problems with this I can fix or there anything else I can do to help get this through? Thanks!

+ end
+
+ it "collects messages logged to the console" do
+ puts subject.console_messages.inspect

This comment has been minimized.

Show comment Hide comment
@jferris

jferris Dec 6, 2011

Owner

Was this left in unintentionally?

@jferris

jferris Dec 6, 2011

Owner

Was this left in unintentionally?

@jferris jferris merged commit 24ccd1f into thoughtbot:master Dec 7, 2011

@jferris

This comment has been minimized.

Show comment Hide comment
@jferris

jferris Dec 7, 2011

Owner

Thanks for the patch; this is merged into master.

Owner

jferris commented Dec 7, 2011

Thanks for the patch; this is merged into master.

@joefiorini

This comment has been minimized.

Show comment Hide comment
@joefiorini

joefiorini Dec 7, 2011

Contributor

Thanks for accepting this Joe, sorry about my stray puts :)

Contributor

joefiorini commented Dec 7, 2011

Thanks for accepting this Joe, sorry about my stray puts :)

@nuc

This comment has been minimized.

Show comment Hide comment
@nuc

nuc Dec 14, 2011

I cannot make this to work :(

I'm pretty sure I have the latest version, but when I try page.should_not have_errors I get:

NoMethodError Exception: undefined method 'has_errors?' for #<Capybara::Session>

nuc commented Dec 14, 2011

I cannot make this to work :(

I'm pretty sure I have the latest version, but when I try page.should_not have_errors I get:

NoMethodError Exception: undefined method 'has_errors?' for #<Capybara::Session>
@joefiorini

This comment has been minimized.

Show comment Hide comment
@joefiorini

joefiorini Dec 14, 2011

Contributor

Try page.browser.should_not have_errors.

On Dec 14, 2011, at 7:39 AM, Giorgos Giannoutsosreply@reply.github.com wrote:

I cannot make this to work :(

I'm pretty sure I have the latest version, but when I try page.should_not have_errors I get:

NoMethodError Exception: undefined method 'has_errors?' for #Capybara::Session


Reply to this email directly or view it on GitHub:
#201 (comment)

Contributor

joefiorini commented Dec 14, 2011

Try page.browser.should_not have_errors.

On Dec 14, 2011, at 7:39 AM, Giorgos Giannoutsosreply@reply.github.com wrote:

I cannot make this to work :(

I'm pretty sure I have the latest version, but when I try page.should_not have_errors I get:

NoMethodError Exception: undefined method 'has_errors?' for #Capybara::Session


Reply to this email directly or view it on GitHub:
#201 (comment)

@adsummos

This comment has been minimized.

Show comment Hide comment
@adsummos

adsummos Dec 22, 2011

There seems to be a race condition somewhere. Sometimes I get
|15|TypeError: Result of expression 'b' [undefined] is not an object.
in the console running my tests, but nothing ends up in console_messages. Other times it does end up there.

There seems to be a race condition somewhere. Sometimes I get
|15|TypeError: Result of expression 'b' [undefined] is not an object.
in the console running my tests, but nothing ends up in console_messages. Other times it does end up there.

@chrisnicola

This comment has been minimized.

Show comment Hide comment
@chrisnicola

chrisnicola Mar 16, 2012

Contributor

@joefiorini page.browser is undefined and while page.driver.browser is the error is still:

NoMethodError Exception: undefined method 'has_errors?' for #<Capybara::Driver::Webkit::Browser:0x00000003181750>
Contributor

chrisnicola commented Mar 16, 2012

@joefiorini page.browser is undefined and while page.driver.browser is the error is still:

NoMethodError Exception: undefined method 'has_errors?' for #<Capybara::Driver::Webkit::Browser:0x00000003181750>
@chrisnicola

This comment has been minimized.

Show comment Hide comment
@chrisnicola

chrisnicola Mar 16, 2012

Contributor

Possible that the RSpec API changed. I've fixed it in #297.

Contributor

chrisnicola commented Mar 16, 2012

Possible that the RSpec API changed. I've fixed it in #297.

@KurtPreston

This comment has been minimized.

Show comment Hide comment
@KurtPreston

KurtPreston Dec 9, 2013

I'm getting the same error trying to test for JavaScript errors:

     Failure/Error: expect(page).not_to have_errors
     NoMethodError:
       undefined method `has_errors?' for #<Capybara::Session>

I have the following versions installed:

  • capybara 2.2.0
  • capybara-webkit 1.1.0
  • rspec-rails 2.14.0
  • rspec-core 2.14.7

Any ideas?

I'm getting the same error trying to test for JavaScript errors:

     Failure/Error: expect(page).not_to have_errors
     NoMethodError:
       undefined method `has_errors?' for #<Capybara::Session>

I have the following versions installed:

  • capybara 2.2.0
  • capybara-webkit 1.1.0
  • rspec-rails 2.14.0
  • rspec-core 2.14.7

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment