Using ConsoleListener you can listen to JavaScript Console messages with different levels: DEBUG, LOG,WARNING and ERROR. To start receiving Console messages you need to register ConsoleListener for a specified Browser instance. For example:


browser.ConsoleMessageEvent += delegate(object sender, DotNetBrowser.Events.ConsoleEventArgs e)
{
    Console.WriteLine("Message: " + e.Message);
};


Example

 

MainWindow.xaml


<Window x:Class="ConsoleListenerSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpf="clr-namespace:DotNetBrowser.WPF;assembly=DotNetBrowser"
        Title="MainWindow" Height="350" Width="525"  Closing="Window_Closing">
    <Grid Name="mainLayout">
        <wpf:WPFBrowserView  Name="browserView" />
    </Grid>
</Window>


MainWindow.xaml.cs


using DotNetBrowser;
using DotNetBrowser.WPF;
using System;
using System.Windows;

namespace ConsoleListenerSample
{

   /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            browserView.Browser.
                LoadURL("http://www.google.com");
            browserView.Browser.ConsoleMessageEvent 
                +=Browser_ConsoleMessageEvent;
            browserView.Browser.ExecuteJavaScript
                ("console.error(\"Error message\");");
        }

        private void Browser_ConsoleMessageEvent
            (object sender, DotNetBrowser.Events.ConsoleEventArgs e)
        {
            Console.WriteLine("Message: " + e.Message);
        }
    }
}