How do I correctly pass chrome capabilities into the default webdriver on Katalon studio - chrome-web-driver

I'm currently trying to get a test running on Katalon Studio, and the specific outcome is determined by certain messages showing up in the browser console. I've managed to extract the console logs and can parse them easily enough, but I'm currently only being given the Severe and Warning messages, while the information I need is in the Info messages.
I've managed to figure out what settings I need to apply, but not in a format that I can easily apply via Katalon. The settings I need are, I believe, as follows:
DesiredCapabilities caps = DesiredCapabilities.chrome()
LoggingPreferences logPrefs = new LoggingPreferences()
logPrefs.enable(LogType.BROWSER, Level.INFO)
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs)
Specifically, I need to set the log level to INFO. However, I can't figure out how to correctly apply this through Katalon's Execution settings, which take on a rather different format to most of the code-based variants I've seen elsewhere. I've currently got{"CHROME_DRIVER":{"LoggingPrefs":{"LogType":"BROWSER","Level":"INFO"}}} set in the com.kms.katalon.core.webui.chrome preferences file, and have tried different variants of this, but to no avail.
Just in case this is an extraction problem rather than a setup issue, I'm currently obtaining the logs as follows:
I obtain the webdriver using DriverFactory.getWebDriver(), and extract the logs using LogEntries logs = driver.manage().logs().get("browser")
How do I get the Info-level logs out of this?
Thanks for your time and help,

You can use KeywordLogger.
Following class is needed: import com.kms.katalon.core.logging.KeywordLogger
KeywordLogger log = new KeywordLogger()
log.logInfo("yourLogMsg")
You can use logFailed, logWarning, etc. too.

Related

Structlog different ways to log: msg versus info and debug

I see different ways to use Structlog and I was wondering what the exact difference is.
Let's say I want to log something using Structlog, you could for example use:
logger.msg("My log message")
But there are other ways to log, like info, debug (as in the standard Python logging library) which give you the possibility to say something about the importance of a message (which you can filter using loglevel):
logger.info("This is an info message")
logger.debug("This is a debug message")
The question is: what is the advantage of using logger.msg as compared to the other ways to log like info and debug? Why would I choose logger.msg?
msg() is a remnant from the original generic BoundLogger that tried to have both stdlib and Twisted log methods (msg() hailing from the Twisted end).
If you use structlog's internal filtering system via structlog.make_filtering_bound_logger(), it's equivalent to the info log level.
You can safely ignore it.

watching variables values while nodejs running without stopping at breakpoints

I'm working on a NodeJS project using nodejs 8.1.2 and the IDE is intellij Ultimate.
in general I don't mind using any other editor or kind of debugger if it allows it.
I want to see variables values in real time without stopping at break points at all.
is that at all possible ?
I noticed that google chrome inspect debugger and intellij doesn't do that.. I can't remember ever seeing this feature. so any information regarding the issue would be greatly appreciated.
You can try using spy-js - it allows inspecting variables, etc. without adding breakpoints. See https://blog.jetbrains.com/webstorm/2014/04/spy-js-webstorm-secret-service/#workflow for more info.
I've not seen this feature either.
What I'd do to watch a variable is this:
function watch(variable) {
setInterval(() => { console.log(variable) }, 1000)
}
watch(varaiableToWatch)
Above is a very simple solution with the tradeoff of creating noise in the console logs.
If you want a fully-featured library, this will do the trick: https://github.com/melanke/Watch.JS/

Read Jenkins build console output and set email content

I have certain errors which I set in my code, which should add corresponding error messages to the email content of the final build email.
I was thinking of printing something such as ("EMAIL CONTENT ERROR: _______") to the console, reading through it (in a pre-send groovy script?), and adding corresponding error messages for each error found.
I was thinking of using a pre-send groovy script, setting the mimeMessage object(was reading jenkins email-ext documentation). Would this be viable?
Also, I have never used groovy before, so pointers to how to approach this would be extremely helpful(or a link to where i can find an implementation of something with a similar idea of reading console). Any advice would be greatly appreciated. Thanks in advance!
Can you check attaching "Build Log" This would highlight all the process of build process.
This is a very similar concept to the question here. The technique there was to use the log parser plugin to scan the console output for you, and then use groovy to add all the errors into an email.
This is generally a pretty good idea because it also means that you can view the same set of highlighted errors from jenkins itself, rather than just the email.
There are a couple of ways this is different from your setup, the main points are:
Yes, write errors directly to the console in a known format
Set the log parser up with regular expressions that find your error format
Instead of a pre-send script, in this case you would use a groovy template for your email generation
The template reads the error list from the console parser and adds them to your email. Each one is a link that links back to the jenkins console output.

Cannot write to Event Log from a COM library on Windows Server 2012 AZURE

I created the Event Source using powershell... So the source exists I can see it in event viewer and inside the registry
I've tried what's suggested here in this KB and nothing I do seems to have any affect
http://support.microsoft.com/kb/2028427/en-us
Here's a list of well known SIDS that I just randomly tried a bunch of and still there is no affect and I keep getting the same exception
InvalidOperationException : Cannot open log for source 'XXXXXXXX.Services COM Library"'. You may not have write access.
http://support.microsoft.com/kb/243330/en-us
Here's my code for writing to the source
string sSource;
string sLog = "Application";
var eventLog = new EventLog(sLog);
sSource = "XXXXXXXX.Services COM Library";
eventLog.Source = sSource;
eventLog.WriteEntry(sEvent, entryType);
I issued the following command against both "system" and "application" to get the value for CustomSD
wevtutil gl system > C:\temp\out.txt
I've tried both of those as the root for the CustomSD key and then I tried appending a few different variations to it to make it work
I tried appending the world
(A;;0x3;;;S-1-1-0)
And that didn't work
And then also the SIDS that were indicated for IUSR in that list of common SIDS (http://msdn.microsoft.com/en-us/library/cc980032.aspx).....
this is coming from a COM library that's been registered with REGASM.... I was able to give the COM library access to a directory to write files by giving it IUSR permissions but I can't get it to write to an event source to save my life...
Besides just continuing down the path of trying different other random ACL combinations I'm sort of at a loss of what to try next...
Also if anyone has any suggestions of a better way to debug this or (for example) see the security exception somewhere coming from the asp.net application that would also be helpful.... Changing that REGKEY, rebooting, and then trying to write to the event source all just seem all very arbitrary so it'd be nice to have something with more substance I can look at for debugging this... I used Process Monitor to watch w3wp.exe reach out to the registry and it's reading the KEY that's relevant to the source I'm writing to
HKLM\System\CurrentControlSet\Services\EventLog\Application\XXXXXXXX.Services COM Library
But it's not reading from the CustomSD key so I'm not sure if that's an indicator of anything...

Labelling Neo4j database using Neo4django

This question is related to the github issue of Neo4django. I want to create multiple graphs using Neo4j graph DB from Django web framework. I'm using Django 1.4.5, neo4j 1.9.2 and neo4django 0.1.8.
As of now Neo4django doesn't support labeling but the above is my core purpose and I want to be able to create labels from Neo4django. So I went into the source code and tried to tweak it a little to see if I can make this addition. In my understanding, the file 'db/models/properties.py' has class BoundProperty(AttrRouter) which calls gremlin script through function save(instance, node, node_is_new). The script is as follows:
script = '''
node=g.v(nodeId);
results = Neo4Django.updateNodeProperties(node, propMap);
'''
The script calls the update function from library.groovy and all the function looks intuitive and nice. I'm trying to add on this function to support labeling but I have no experience of groovy. Does anyone have any suggestions on how to proceed? Any help would be appreciated. If it works it would be a big addition to neo4django :)
Thank you
A little background:
The Groovy code you've highlighted is executed using the Neo4j Gremlin plugin. First it supports the Gremlin graph DSL (eg node=g.v(nodeId)), which is implemented atop the Groovy language. Groovy itself is a dynamic superset of Java, so most valid Java code will work with scripts sent via connection.gremlin(...). Each script sent should define a results variable that will be returned to neo4django, even if it's just null.
Anyway, accessing Neo4j this way is handy (though will be deprecated I've heard :( ) because you can use the full Neo4j embeddeded Java API. Try something like this to add a label to a node
from neo4django.db import connection
connection.gremlin("""
node = g.v(nodeId)
label = DynamicLabel.label('Label_Name')
node.rawVertex.addLabel(label)
""", nodeId=node_id)
You might also need to add an import for DynamicLabel- I haven't run this code so I'm not sure. Debugging code written this way is a little tough, so make liberal use of the Gremlin tab in the Neo4j admin.
If you come up with a working solution, I'd love to see it (or an explanatory blog post!)- I'm sure it could be helpful to other users.
HTH!
NB - Labels will be properly supported shortly after Neo4j 2.0's release- they'll replace the current in-graph type structure.

Resources