How to capture console error logs using selenium4 ruby? - 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,
The below actual errors are not capturing on the logs,
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.

Related

Zap stack traces vs. error messages on google cloud

I'm using zapp to log error messages on a service hosted on google cloud, and am seeing that while errors are logged successfully, the text stored in the "message" field of the google cloud log is the stack trace, and not the error message I have logged.
Example code:
var log *zap.Logger
if err := doStuff(); err != nil {
log.Error(<error message I want to log>, zap.Error(err))
}
This works well except google cloud logging and stackdriver will use the stack-trace caught by the call to zap.Error in the message field of the structured log. The message I've defined appears in the msg field, but the former appears to be the one displayed predominantly in the logging console and used by stackdriver for indexing errors.
This means that when navigating logs and errors via the console, I only see stacktraces, and no indication of the associated error string.
The tricky thing is I have no idea if this "issue" is cloud-side or zapp-side. I've spent some time digging around in Zapp to no avail, and am out of ideas.
zap by default puts the message under the msg key, the stacktrace under stacktrace, and prints log lines as json to stdout. You should be able to see this in action by just running your binary locally.
Your logging system presumably processes these log lines as they're printed. It will read them, parse them, and maybe do some restructuring or add some metadata, and then send them off somewhere else to be saved or processed more.
Since zap is in all likeliness working as intended, you need to look at the system that processes your logs. How does it expect them to look? Does it have special rules for any particular keys? Will it inject any keys of its own?
Note that you can configure zap to use different keys for all of its standard fields.
To log correctly and effectively on GCP, first, you have to set appropriate Zap keys with the Logging's LogEntry
In case you are looking for a working example, I write a simple Zap config here:
https://github.com/uber-go/zap/discussions/1110#discussioncomment-2955566

How to log errors when Play Evolutions fail?

I am just getting started with Play Evolutions and I find it pretty tough to figure out why they fail and leave the DB in an inconsistent state.
In Dev mode it will display the error in the default HTML page but it does not say which statement failed. This is also problematic since for this particular application I only have REST APIs that return JSON and so an HTML error is not appropriate. I have my own error handler so I will probably end up matching on ExceptionAttachment and pull out the content/script myself and escape that in the JSON error response. However this is only in DEV mode since I would not want this going back to a real user in PROD.
More frustrating is that it doesn't even log the statement when it fails. I can enable logging for my driver but once the failure has occurred it is too late to then go and enable logging.
Is there anyway to get a more specific error in the logs when an evolution fails?

Is MediaProtocolCommand.Listener onCompleted called when it fails to load a video?

I am on purpose sending a video with a format that is not supported to my receiver app. I see the following message on the chromcast console:
[ 8.188s] [cast.receiver.ChannelOverWebSocket] Sending message:
["ramp",{"cmd_id":1,"type":"RESPONSE","status":{"event_sequence":10,"error":{"domain":"ramp","code":-2}}}]
from ws://localhost:8008/session?20
How do I receive that on my android app? I know onComplete for the MediaProtocolCommand.Listener is called when the video plays fine. The description makes it sound like it would also be called when it doesn't play or am I reading that wrong?
I've also tried looking into the MediaProtocolCommand returned by mMessageStream.loadMedia on a separate thread in an infinite loop and it never gets its hasError set to true. So what am I missing?
Thanks.
It appears that the Cast Android SDK isn't parsing these error messages correctly. In the sample Android client, the following exception is thrown with an invalid video URL:
MediaProtocolMessageStream(9088): error parsing message:
{"type":"RESPONSE", "cmd_id":1,"status":{"error":{"domain":"ramp","code":-2},
"event_sequence":377}} org.json.JSONException: No value for state
This looks like a bug and should be reported to Google.

clear up GM_log from error console

Is there a way to clear up GM_log messages from error console from userscripts on a certain event?
I don't want to clear up manually. On trigger of certain event, want to clear up the old log from the error console and show up the new log.
You cannot clear the error console. If you could, evil websites could clear it too and erase the record of their misdeeds.
You should no longer use GM_Log() anyway. Use Firebug and the excellent console logging functions it provides.
Then you can use console.clear().
Note, to avoid conflicts with Firefox's newish console functions, and to ensure that the output appears in Firebug's console, you may need to prefix the calls with unsafeWindow.
So your script could do something like this:
unsafeWindow.console.clear ();
unsafeWindow.console.time ('ScriptRun');
unsafeWindow.console.log ("Script start." );
unsafeWindow.console.timeEnd ('ScriptRun');
Which would look like this in the Firebug console:
-- with all the preceding cruft erased. (Anything the webpage does after the clear() call will still appear though.)

invalid encoding when uploading an image to rails using javascript

I'm using qqfileupload (http://valums.com/ajax-upload/) to create a single drag & drop image upload interface.
The request is being sent to rails, and my rails console is returning
!! Unexpected error while processing request: invalid %-encoding (����JFIFdd��Ducky��Adobed)
which I assume is rails attempting to read the file.
I set my controller to output
return render :text => params
thinking that I could look at what the server was recieving, but I only get the Unexpected error again, which to me says that Rails is hitting this error before getting to the controller.
The params from the javascript console shows
http://localhost:3000/users?qqfile=me.jpg&first_name=&last_name=
the first and last fields are supposed to be blanks.
I stared following this tutorial http://css-tricks.com/ajax-image-uploading/, which looked very similar to the case I was already using, and it lead to this download script http://valums.com/ajax-upload/, which is almost identical to the one I had before, but somehow is slightly different and doesn't return the error above.
Hopefully this helps somebody out.

Resources