Я новичок в casperjs и я хочу проверить выпадающий список с этой страницы: http://www.spareka.fr/pieces_detachees_accessoires_electromenagerCasperJS, тестовая страница не загружается полностью
элемент находится в правом верхнем углу страницы ("Quel типа d'appareil? "). Итак, я запускаю этот скрипт:
...
this.fillSelectors("form#search_form_4", {
...
...
});
...
Но моя оболочка отображать эту ошибку: «Форма не найдена» я проверил, и селектор хорошо. Итак, я фиксирую страницу в начале моего скрипта, и я заметил, что моя страница не загружает все элементы (форма с идентификатором «search_form_4» не видна).
Я thinked моей страницы нужно время для загрузки, так что я использую this.wait так:
...
this.capture("screen01.png");
this.wait(100000, function(){
this.capture("screen02.pbg");
});
...
Но в конце концов, экран screen01 показывает ту же информацию, что и screen02. Я не понимаю, почему страница не загружается полностью, когда я использую CasperJS:/Можете ли вы мне помочь?
Edit: Мои журналы:
[email protected] ~/Bureau/tests casper/test $ sudo casperjs script_test.js
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: http://www.spareka.fr/piece_detachees_accessoires_electromenager , HTTP GET
[debug] [phantom] Navigation requested: url= http://www.spareka.fr/piece_detachees_accessoires_electromenager , type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to " http://www.spareka.fr/piece_detachees_accessoires_electromenager "
[debug] [phantom] Navigation requested: url= http://googleads.g.doubleclick.net/pagead/viewthroughconversion/1009678515/?random=1413232851719&cv=7&fst=1413232851719&num=1&fmt=1&guid=ON&u_h=768&u_w=1024&u_ah=768&u_aw=1024&u_cd=32&u_his=1&u_tz=120&u_java=false&u_nplug=0&u_nmime=0&frm=0&url=http://www.spareka.fr/piece_detachees_accessoires_electromenager , type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url= http://www.google.com/ads/user-lists/1009678515/?fmt=1&num=1&cv=7&frm=0&url=http://www.spareka.fr/piece_detachees_accessoires_electromenager&random=4196938409 , type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url= http://www.google.fr/ads/user-lists/1009678515/?fmt=1&num=1&cv=7&frm=0&url=http://www.spareka.fr/piece_detachees_accessoires_electromenager&random=4196938409&ipr=y , type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/2 http://www.spareka.fr/piece_detachees_accessoires_electromenager (HTTP 200)
[debug] [phantom] Capturing page to /home/asus4/Bureau/tests casper/test/screen01.png
[info] [phantom] Capture saved to /home/asus4/Bureau/tests casper/test/screen01.png
[info] [phantom] Step anonymous 2/2: done in 3227ms.
[info] [phantom] Step _step 3/3 http://www.spareka.fr/piece_detachees_accessoires_electromenager (HTTP 200)
[info] [phantom] Step _step 3/3: done in 3228ms.
[info] [phantom] wait() finished waiting for 10000ms.
[debug] [phantom] Capturing page to /home/asus4/Bureau/tests casper/test/screen02.png
[info] [phantom] Capture saved to /home/asus4/Bureau/tests casper/test/screen02.png
CasperError: Errors encountered while filling form: form not found
/home/asus4/Bureau/dev/casperjs/modules/casper.js:805 in fillForm
/home/asus4/Bureau/dev/casperjs/modules/casper.js:880 in fillSelectors
/home/asus4/Bureau/tests casper/test/script_test.js:28
/home/asus4/Bureau/dev/casperjs/modules/casper.js:2035 in _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',
});
});
Я обновляю свой первый пост =) Я следил за вашими советами, но я не нашел никакой важной ошибки ... – user2137454