How can I check a browser console for errors?
For example, I have raised browser(chrome of firefox) with Selenium and I have done some actions with Selenium WebDriver. After than I want to know is there any error in the web console.
Google Chrome: In Google Chrome, the Console Logs are available as a part of Chrome Dev Tools. To open the dedicated Console panel, either: Press Ctrl + Shift + J (Windows / Linux) or Cmd + Opt + J (Mac).
One of the best tools in a rails developers arsenal is the rails console, being extremely useful for brainstorming, debugging, and testing. Having it log active record queries directly to the console can improve readability and convenience over looking through the development logs to see what SQL queries have been run.
I tried to take console error like:
def check_console_log
console_log = @browser.driver.manage.get_log(:browser)
if console_log != nil
raise(console_log)
end
end
and also log it to file
def write_log(file_path)
work_log = @browser.driver.manage.get_log(:browser)
messages = ""
work_log.each { | item | messages += item.message + "\n"}
File.write( "#{file_path}.log", messages ) unless messages == ""
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With