Logging value of a variable in MonkeyTalk IDE Javascript file
Asked Answered
M

1

2

I'm using MonkeyTalk IDE Beta2 for testing iPad application. I exported the javascript from the MonkeyTalk IDE and got a new .js file. I am storing the Boolean value of a Verify command in a var and want to see what is its value, and accordingly do custom logic. I tried document.write, console.log and alert used in javascript but got an error that they are not defined. Please help me with this.

Also, is it possible to output the result of a test as XML (as in FoneMonkey) or as an Excel spreadsheet or something like that?

Thank you in advance.

Mercurous answered 25/4, 2012 at 7:19 Comment(0)
R
0

Believe it or not*, but to date there is no way direct way to cause MonkeyTalk to log messages to the console. What you can do, however, is abuse a command like verifyNot which will result in a log message. In a MonkeyTalk .mt this would be done like:

View * VerifyNot Message

I created the following helper script called log.js for this purpose. Timestamps are automatically added by Eclipse, but not elsewhere so I have prepended the time.

load("libs/Executor.js");

function getTimeStamp() {
    var now = new Date();
    return now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
}

EXECUTOR.defineScript("Log", function(msg) {
    this.app.view().verifyNot(getTimeStamp() + ": " + msg);
});

Finally, you don't need the executor boilerplate (only the verifyNot line), but we use that with scripts by Doba in order to be able to organize files in different directories (Doba.js renamed to Executor.js) -- another feature not available out of the box.

* It's almost like GorillaLogic doesn't want you to be able to resolve your own problems. ;)

Robinet answered 15/1, 2013 at 20:57 Comment(1)
And to address your second question, I don't have any knowledge of a capability like that either.Robinet

© 2022 - 2024 — McMap. All rights reserved.