本文介绍了在MonkeyTalk IDE Javascript文件中记录变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MonkeyTalk IDE Beta2测试iPad应用程序.我从MonkeyTalk IDE导出了javascript,并得到了一个新的.js文件.我将Verify命令的布尔值存储在var中,想要查看其值是什么,并因此执行自定义逻辑.我尝试在JavaScript中使用document.writeconsole.logalert,但收到未定义的错误.请帮助我.

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.

还可以将测试结果输出为XML(例如FoneMonkey中的XML)或Excel电子表格等吗?

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?

谢谢.

推荐答案

信不信由你,*到目前为止,还没有直接的方法可以使MonkeyTalk将消息记录到控制台.但是,您可以做的是滥用verifyNot之类的命令,该命令将产生一条日志消息.在MonkeyTalk .mt中,操作如下:

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

我为此创建了以下名为log.js的帮助脚本.时间戳是Eclipse自动添加的,但不是在其他地方添加的,因此我已经提前了时间.

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);
});

最后,您不需要执行程序样板文件(仅需要verifyNot行),但是我们将其与脚本(Doba.js重命名为Executor.js).框.

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.

*几乎就像GorillaLogic并不希望您能够解决自己的问题. ;)

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

这篇关于在MonkeyTalk IDE Javascript文件中记录变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!