本文介绍了使用slimer.js运行casper.js测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用casperjs编写了一些测试。它们与phantomjs正常运行。但是,当我尝试通过以下命令使用slimerjs时:

I wrote a few tests with casperjs. They run just fine with phantomjs. However, when I tried to use slimerjs with the following command:

casperjs --verbose --engine=slimerjs test create-project-suite.js

一个带有SlimerJs徽标和版本号的小窗口,但控制台似乎挂起了并显示以下行:

A small window appers with the SlimerJs logo and version number but the console seems to hang with the following line:

Test file: create-project-suite.js

我还有什么需要做的吗?版本号如下:

Is there anything else I need to do? Here are the version numbers:

Mozilla Firefox 28.0
CasperJS version 1.1.0-beta3
Innophi SlimerJS 0.9.1
3.8.0-37-generic #53~precise1-Ubuntu

更新:

我删除了代码,直到获得slimerjs才能打开浏览器并执行测试。似乎每当我需要一个js文件(我遵循页面对象模式)时,它就会挂起:

I removed code until I got slimerjs to open the browser and execute tests. It seems that it hangs whenever I require a js file (I'm following the page objects pattern):

var Login = require('./objects/login');

我认为可能会有所帮助。 关于如何解决此问题的任何想法?

I think require.paths could be helpful. Any ideas on how to get around this?

推荐答案

使用完整路径会使slimerjs很高兴:

Using full paths makes slimerjs happy:

var path = fs.absolute(fs.workingDirectory + '/objects/login');
var Login = require(path);

将所有模块移动到脚本所在的目录更加简单。

It is plain simpler to move all modules to the same directory where the script is.

这篇关于使用slimer.js运行casper.js测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 09:20