casperjs

CasperJS posting only the last item multiple times from my for-loop

流过昼夜 提交于 2019-12-20 06:39:59
问题 CasperJS is awesome but it's not posting to my localhost what my console output is. casper.wait(5000, function () { casper.wait(1000, function () { casper.then(function(){ for (var i = 0 ; i < 10; i++) { var description = casper.fetchText(x('//*[@id="acDataId-local'+i+'"]/a')); //*[@id="acDataId-local0"]/a console.log(description); var target_date = casper.fetchText(x('//*[@id="dtDataId-local'+i+'"]/text()[1]')); console.log(target_date); var target_location = casper.fetchText(x('//*[@id=

Running multiple instances of casperjs

耗尽温柔 提交于 2019-12-20 05:44:14
问题 I need to run 3 url requests simultaneously.I thought of running 3 casper instances each fetching a url. As a simple example,I tried with 2 instances. var casper=require('casper').create(); casper.start('http://www.google.com'); var casper1=require('casper').create(); casper1.start('http://www.google.com'); casper1.then(function() { casper1.echo('inside'); }); casper1.echo('outside'); casper1.run(); casper.run(); Output shows only 'outside'.Why does'nt it run the casper1.echo('inside'); 回答1:

CasperJS click not firing click event

荒凉一梦 提交于 2019-12-20 04:35:10
问题 I am having trouble with CasperJS. I load the page for our site, then try to click on the signup button. It's supposed to open a modal, but nothing happens. It works in actual browsers, and very similar functionality works in other tests on other pages. What could I be doing wrong? What else would help you, the wider internet, help me? casperjs --version: 1.1.0-beta3 phantomjs --version: 1.9.7 Casper test snippet: casper.then(function() { casper.open(DOMAIN); }); // wait added for debugging.

Cant get “this.mouse.click()” to work with casperjs

时间秒杀一切 提交于 2019-12-20 01:59:16
问题 Im trying to understand casperjs but struggling with this. Can someone pleas tell me why this works (it navigates to http://www.w3schools.com/html/default.asp): var casper = require('casper').create(); var mouse = require("mouse").create(casper); casper.start('http://www.w3schools.com/'); casper.then(function(){ this.click('a.btn'); }); casper.then(function(){ console.log('Location is now: ' + this.getCurrentUrl()); }); casper.run(); But if i replace this.click('a.btn'); with this.mouse.click

Using CasperJS as a Portable Installation?

陌路散爱 提交于 2019-12-19 10:57:07
问题 I'm trying to run CasperJS in a portable way that doesn't involve setting the path variable in Windows. Currently I have gotten this to partially work by moving the phantomjs executable along with the entire contents of the CasperJS directory to the batchbin folder. I also edited the batch file to make it initialize casperJS using the current directory, which is where all the files are located. Here is my directory with all the files: http://i.imgur.com/ByTjU0s.png My casperjs.bat file: @ECHO

CasperJS Can't find variable $

假如想象 提交于 2019-12-19 07:55:57
问题 I'm trying to inject jQuery in my test but I get the following error: ReferenceError: Can't find variable: $ It is a ruby on rails application I'm trying to test, running on WEBrick. Here's all of the code: var casper = require('casper').create({ clientScripts: ['jquery-1.9.1.min.js'] }); //make sure page loads casper.start('http://127.0.0.1:3000', function() { this.test.assertTitle('EZpub', 'EZpub not loaded'); }); //make sure all 3 fridges are displayed casper.then(function() { //get

Set screen resolution in CapserJS/SlimerJS

♀尐吖头ヾ 提交于 2019-12-19 05:07:38
问题 Im using CasperJS 0.10.1 SlimerJS 1.1.3 Firefox 45 on CentOS 7.2 Im trying to set the window.screen properties as seen by the code below by the screenshot of the website still says 640x480 var casper = require('casper').create({ verbose: true, logLevel: 'debug' }); casper.on('page.initialized', function (page) { page.evaluate(function () { (function() { window.screen = { width: 1600, height: 900 }; }) }); }); casper .start() .thenOpen('http://www.whatismyscreenresolution.com/') .wait(5000,

Issues running casperjs with phantomjs#2.0.0 on Mac (Yosemite)

拥有回忆 提交于 2019-12-19 01:47:53
问题 I'm trying to run CasperJS having PhantomJS#2.0.0 on a Mac(Yosemite) . When trying to run CasperJS I´m getting the following message: "CasperJS needs PhantomJS v1.x /usr/local/Cellar/casperjs/1.1-beta3/libexec/bin/bootstrap.js:91 in __die" How can I make it run? Has anyone got it working? 回答1: Currently there is no newer version than 1.1-beta3 released which contains this check. The simplest fix would be to open the bin/bootstrap.js file and remove these lines or replacing the lines that are

Casperjs: How can I print http requests and responses?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 12:28:19
问题 For debugging purporses I need to see the whole request: headers and data. How can I achieve this? 回答1: Casper (well, actually PhantomJS) supplies two callbacks, one when the resource is requested (where you can see headers being sent), and one when response is received (so you can see the headers the server replied with): var utils = require('utils'); var casper = require('casper').create(); casper.options.onResourceRequested = function(C, requestData, request) { utils.dump(requestData

Select value from dropdown list using the text

和自甴很熟 提交于 2019-12-18 09:45:39
问题 How do you select a value from a dropdown list, by using the text, instead of the value or the index? The HTML: <select name="category_group" id="category_group" sel_id="" > <option value="0" selected="selected">Kies de rubriek</option> <option value='1000' style='background-color:#dcdcc3;font-weight:bold;' disabled="disabled" id='cat1000' > -- VOERTUIGEN -- </option> <option value='1020' id='cat1020' > Auto's </option> <option value='1080' id='cat1080' > Auto's: Onderdelen </option> <option