Phantomjs CasperJS,测试页面没有';不完全加载
我是casperjs的新手,我想测试此页面的下拉列表: 元素位于页面的右上角(“Quel type d'appareil?”)。 因此,我运行以下脚本:Phantomjs CasperJS,测试页面没有';不完全加载,phantomjs,casperjs,Phantomjs,Casperjs,我是casperjs的新手,我想测试此页面的下拉列表: 元素位于页面的右上角(“Quel type d'appareil?”)。 因此,我运行以下脚本: ... this.fillSelectors("form#search_form_4", { ... ... }); ... 但我的shell显示此错误:“找不到表单” 我检查过了,选择器很好。因此,我在脚本的开头捕获了页面,我注意到我的页面没有加载所有元素(id为“search\u form\u 4”的表单不可见) 我想我的页面需
...
this.fillSelectors("form#search_form_4", {
...
...
});
...
但我的shell显示此错误:“找不到表单”
我检查过了,选择器很好。因此,我在脚本的开头捕获了页面,我注意到我的页面没有加载所有元素(id为“search\u form\u 4”的表单不可见)
我想我的页面需要时间来加载,所以我使用这个。像这样等待:
...
this.capture("screen01.png");
this.wait(100000, function(){
this.capture("screen02.pbg");
});
...
但最终,screen01显示的内容与screen02相同。
我不明白为什么我使用CasperJS时页面没有完全加载:/能帮我吗
编辑:
我的日志:
asus4@asus4-VirtualBox~/Bureau/tests casper/test$sudo casperjs script_test.js[信息][幻影]正在启动…
[信息][幻影]跑步套件:两步
[调试][幻影]打开url:,HTTP GET
请求的[调试][幻影]导航:url=,type=Other,willNavigate=true,isMainFrame=true
[debug][phantom]url已更改为“”
请求的[调试][幻影]导航:url=,type=Other,willNavigate=true,isMainFrame=false
请求的[调试][幻影]导航:url=,type=Other,willNavigate=true,isMainFrame=false
请求的[调试][幻影]导航:url=,type=Other,willNavigate=true,isMainFrame=false
[debug][phantom]已成功注入Casper客户端实用程序
[信息][幻影]步骤匿名2/2(HTTP 200)
[调试][幻影]将页面捕获到/home/asus4/Bureau/tests casper/test/screen01.png
[信息][幻影]捕获保存到/home/asus4/Bureau/tests casper/test/screen01.png
[信息][幻影]步骤匿名2/2:在3227毫秒内完成。
[信息][幻影]步骤_步骤3/3(HTTP 200)
[信息][幻影]步骤\u步骤3/3:在3228毫秒内完成。
[信息][幻影]等待()已完成10000毫秒的等待。
[debug][phantom]将页面捕获到/home/asus4/Bureau/tests casper/test/screen02.png
[信息][幻影]捕获保存到/home/asus4/Bureau/tests casper/test/screen02.png
CasperError:填写表单时遇到错误:找不到表单
/home/asus4/Bureau/dev/casperjs/modules/casper.js:805格式填写
/home/asus4/Bureau/dev/casperjs/modules/casper.js:880在fillSelectors中
/home/asus4/Bureau/tests casper/test/script_test.js:28
/home/asus4/Bureau/dev/casperjs/modules/casper.js:2035 in\u check 我的代码:
var casper = require("casper").create({
verbose: true,
logLevel: "debug"
});
casper.start("http://www.spareka.fr/piece_detachees_accessoires_electromenager", function(){
//this.echo(this.getHTML('body'));
this.on('remote.message', function(msg){
this.echo("remote.message : " + msg);
});
this.on('page.error', function(msg, trace){
this.echo("Error: " + msg, "ERROR");
this.echo("file: " + trace[0].file, "WARNING");
this.echo("line: " + trace[0].line, "WARNING");
this.echo("function: " + trace[0]["function"], "WARNING");
errors.push(msg);
});
this.capture("screen01.png");
this.wait(10000, function(){
this.capture("screen02.png");
this.fillSelectors("form#search_form_4", {
//'input[id="#finalProductType"]': 'Appareil à Fondue',
//'input[id="#manufacturer"]': 'TEFAL',
});
});
您应该使用“form#search-form-4”
用破折号替换下划线。我检查了你提到的页面,它有一个id=“search-form-4”的表单。I refresh my first post=)我听从了你的建议,但没有发现任何重要错误……但奇怪的是,我在firebug explorer中看到了下划线