问题标签 [slimerjs]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1054 浏览

node.js - Unable to upgrade - slimerjs missing...?

I'm running on OSX (El Capitan) with node v5.0.0 and npm v3.3.9. if I attempt an upgrade:

I get the error below:

I've tried uninstalling this slimerjs (whatever that is) both locally and globally but it still fails. if I look in the given directory there is indeed no 0.9.5 installed but I do find a 0.9.6

so what requires it and why isn't it satisfied with the later version? and most importantly, how do I fix it?

0 投票
1 回答
132 浏览

slimerjs - 无法传播退出代码

我尝试像这样退出我的javascript代码:

但我没有得到 1 退出代码。我什至尝试:

我永远得到退出代码0。

任何想法/帮助?

0 投票
1 回答
718 浏览

javascript - 使用 SlimerJS 获取 AJAX 请求的响应正文

我正在使用SlimerJS为网站编写测试,需要检查来自服务器的响应正文。我正在使用以下代码来获取响应:

我确实收到了响应,但是因为默认情况下为了防止过多的内存使用SlimerJS 使响应主体保持为空,所以我也收到一个空的主体,除非我告诉它不要使用类似这样的方法将某些格式的主体保持为空:

我知道这适用于具有 css、jpg 和 avi 等扩展名的文件,但是来自服务器的 AJAX 响应呢?响应为 JSON 格式,响应正文为空。

0 投票
0 回答
1546 浏览

python - How to call slimerJs in a python?

All the code I read on slimer seems java based.

I read here that you can run slimer as a selenium driver but I have no idea how to set it in python.

I tried:

It was a long shot but I read that slimer is made to accept phantom code so I thought that might be the case. But not surprisingly that didn't work.

So any idea how to set it as the driver in the script? The link above just shows the command line arguments so I don't know how it would 'plug in' to the code in my python project?

0 投票
0 回答
1036 浏览

phantomjs - Casperjs 不执行 javascript 代码

我有一个页面,我在页面的标题中引用了一堆带有常规脚本标记的脚本:jQuery 等,以及我编译的名为 index.js 的脚本。后者很大,大约 120 万(不要问为什么)。

我的 index.html 看起来像这样:

问题是如果我使用 PhantomJS 引擎,我的脚本不会在任何平台上执行。如果我使用 SlimerJS/XUL,那么它会在 Windows 上执行,但不会在 OSX 上执行。我用常规的waitFor验证它,评估一个全局变量的值,没什么特别的:

另一方面,jQuery 在任一环境中都被初始化,我可以在评估上下文中很好地运行 jQuery 代码,所以这将通过:

如果我注销页面事件,我可以看到 index.js 加载的 HTTP 结果为 200,它只是没有被执行。

以前有人经历过吗?PhantomJS 或 SlimeJS 是否对脚本大小/复杂性有一些特定于平台的限制?

0 投票
0 回答
290 浏览

javascript - CasperJS:递归 casper.open 在第二次出现时因 ajax 响应而失败

我正在使用 casperJS 和 slimerJS 引擎来获取由 ajax 响应加载的视频。

脚步

  1. 获取网址列表
  2. 对列表中的每个 url 递归调用 casper.open
  3. 每个casper.open调用都需要等待前面的casper.open发送一个 ajax 响应。

前两点效果很好。我对第三个有问题。重要的是要了解我不需要等待页面完成加载才能加载下一个casper.open。我只需要等待来自每个 url 的一个 ajax 响应。当我收到此回复时,我可以关闭此网址并打开下一个。

为此,递归循环从第一次出现开始。然后,使用 resource.received 事件监听网络并等待特殊的 contentType。这个 contentType 给了我响应,我可以在其中找到加载视频的 url。我将此 url 存储在一个数组中,并且可以关闭 thise casper.open并开始下一个。

这是我的代码:

问题是第一个casper.open打开页面,等待捕获好的 contentType 并将好的 url 存储在我的数组源中。然后,下一个casper.open被调用,程序永远处于等待状态。这是因为 contentType 永远不会被捕获......但它与上一个页面是同一类型的页面。如果我先从第二页开始,它会起作用。只有递归循环的下一次出现不起作用,第一次出现无关紧要。
此外,如果我在浏览器(chrome 或 firefox)中打开这些页面,它工作得很好,他抓住了 contentType。所以,问题来自我的程序。
在 resource.received 侦听器期间有时我会出错:“错误类型 $.cookie”。但即使我有 jquery.cookie.js,它也不起作用。

我试图关闭页面或存储 cookie 并清除每个casper.open之间的页面,但它仍然无法正常工作。

先感谢您。

0 投票
0 回答
362 浏览

iframe - 使用 SlimerJS(或 PhantomJS)更改 iframe 中的导航器数据

通过一种或另一种技巧,我设法使用 SlimerJS 处理新窗口(window.open、target=blank 等)和 iframe 中的标题。也可以为新窗口更改导航器数据(例如 navigator.appVersion),但我坚持为 iframe 执行此操作。看起来 onInitialized 方法仅适用于主窗口和新窗口,但不适用于 iframe。

这是代码的一些部分。

我尝试使用 PhantomJS 执行此操作,但在以下情况下似乎无法使用“this”而不是“webpage”:

我希望此函数与“this”对象一起使用,以便可以将其定义为主页面和子页面的 onInitialized。

无论如何,主要问题是关于 SlimerJS 代码,而不是 Phantom 代码。

0 投票
3 回答
810 浏览

phantomjs - SlimerJS 中的处理下载对话框

我编写了一个脚本,可以单击可以下载 mp3 文件的链接。我面临的问题是当脚本模拟点击该链接时,会弹出一个下载对话框,如下所示:
下载对话框

现在,我想将此文件保存到我选择的某个路径并自动化整个过程。我对如何处理这个对话框一无所知。

0 投票
1 回答
1238 浏览

node.js - 缺少 SLIMERJSLAUNCHER 环境变量。使用 Firefox 或 XulRunner 的路径设置它

每个人!

当我尝试在 casper 中运行一项测试时: casperjs --engine=slimerjs test.js

得到了这个味精

SLIMERJSLAUNCHER environment variable is missing. Set it with the path to Firefox or XulRunner

XulRunner,Firefox 已安装。我正在使用 Mac OS。

0 投票
0 回答
450 浏览

javascript - 如何使用 PhantomJS 从 SlimerJS 的对话框中下载文件?

我正在使用 PhantomJS 和 SlimerJS 从网络下载 .xls 文件。

我没有下载地址。该文件是自动生成的。

我尝试了 CasperJS,但我做不到。

如何下载这个文件?

从 Dialog Box SlimerJS 捕获 JPG 示例