nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.79k stars 1.31k forks source link

Detect JavaScript errors #77

Closed Yogu closed 10 years ago

Yogu commented 10 years ago

It would be cool if nightwatch failed a test when a javascript error occurs in the browser. I think the JSErrorCollector extension for firefox and for chrome can do this. Do you think it's possible to integrate them into nightwatch?

beatfactor commented 10 years ago

Looks cool, I think it might be fairly easy to integrate this. I'll look into it.

davidlinse commented 10 years ago

+1

rcherny commented 10 years ago

We just do this in our app with the window.onerror, write them to an array, and then always check the JS errors in an execute() at the end of our tests. It's no where near as robust but gets you somewhere near there in the meantime.

davidlinse commented 10 years ago

Another way to solve this is probably #222 ?

Yogu commented 10 years ago

@beatfactor What's the state on this issue? Why did you close it?

andreiebuddy commented 10 years ago

Because I don't think it will become part of the API. From what I can tell It could be implemented via a browser extension and a custom command/assertion. Would that work for you?

On Monday, September 1, 2014, Jan Melcher notifications@github.com wrote:

@beatfactor https://github.com/beatfactor What's the state on this issue? Why did you close it?

— Reply to this email directly or view it on GitHub https://github.com/beatfactor/nightwatch/issues/77#issuecomment-54093249 .

rfink commented 9 years ago

+1

maxgalbu commented 9 years ago

@beatfactor It could be implemented via a browser extension using JSErrorCollector, but how can we integrate a custom extension in nightwatch?

From JSErrorCollector docs there's an example in ruby:

profile = Selenium::WebDriver::Firefox::Profile.new
profile.add_extension File.join(Rails.root, "features/support/extensions/JSErrorCollector.xpi")
Capybara::Selenium::Driver.new app, :profile => profile 

in python and chromeJSErrorCollector:

chrome_options = Options()
chrome_options.add_extension('extension.crx')
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('http://stuff-dharrya.rhcloud.com/get_js_error')
print(driver.execute_script('return window.JSErrorCollector_errors ? window.JSErrorCollector_errors.pump() : []')) 
driver.quit()

Can we do the same thing in nightwatch?

vvscode commented 9 years ago

What is the current state of request ? is there example how to solve ?

IndraniBiswas commented 8 years ago

was this solved ?

travco commented 8 years ago

@vvscode , @IndraniBiswas , This was solved as part of #609.

The route you have to go at it is a little roundabout, but the documentation is here: http://nightwatchjs.org/api/getLog.html

mikkopori commented 7 years ago

Has someone implemented this? Are there any working end-to-end examples available?

vvscode commented 7 years ago

@mikkopori https://stackoverflow.com/questions/29443804/save-console-messages-for-debugging-in-nightwatch-js/29502982