'How to capture console error logs using selenium4 ruby?

We are trying to capture the console log error's which is throw from front end errors. Below code snippet used for capture the logs,

$driver.on_log_event(:console) do |event|
        $logs.push(event)
    end

By this code snippet we could capture only the browser default and not capturing the application thrown errors. Are we missing anything here.

This error's are captured from console, enter image description here

The below actual errors are not capturing on the logs,

enter image description here

I could able to capture console error's using selenium4 method "on_log_event" method. But need to capture the network api error as well.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source