casperjs

How can I extract an input value by id with CasperJS?

血红的双手。 提交于 2019-12-24 12:33:29
问题 I have a casperjs problem. I can't extract value from an id with javascript. I am opening google, searching a term, and i want to get the value from the searchbox by id. var casper = require('casper').create({ verbose: true, logLevel: "info" }); var mouse = require("mouse").create(casper); var x = require('casper').selectXPath; var webPage = require('webpage'); var page = webPage.create(); casper.userAgent('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171

Casperjs 1.1 does not generate XUnit xml file

守給你的承諾、 提交于 2019-12-24 11:47:44
问题 I am running CasperJS tests. I tried to generate xUnit xml file in output rendering. But this fails when ever a single FAILure occurs. Actually the executing stopped when a single FAIL occurs. Here is the script that I am working on casper.test.begin('Site login', '', function suite(test) { casper.start(mysite, function () { test.assertExists('form#index', "Login Form found"); //Pass test.assertExists('form#index1', "Login Form found"); //Fail }); casper.run(function (){ test.done(); test

CasperJS running out of memory

早过忘川 提交于 2019-12-24 11:05:20
问题 I'm running the following script with CasperJS and after about 1/3rd of the way through the array it starts running out of swap space and the machine becomes extremely slow. What am i doing wrong here? searchPages is an array of 54 numbers corresponding to a URL value for a search page. casper.each(searchPages,function(casper,index){ loadSearch(casper,index); }); function loadSearch(casper,index){ var currentTime = new Date(); var month = currentTime.getMonth() + 2; var day = currentTime

How to remotely fetch answer of phantomjs script run on heroku?

核能气质少年 提交于 2019-12-24 08:39:28
问题 I want to fetch some information from a website using the phantomjs/casperjs libraries, as I'm looking for the HTML result after all javascripts on a site are run. I worked it out with the following code from this answer: var page = require('webpage').create(); page.open('http://www.scorespro.com/basketball/', function (status) { if (status !== 'success') { console.log('Unable to access network'); } else { var p = page.evaluate(function () { return document.getElementsByTagName('html')[0]

Phantom/Caperjs User input

拜拜、爱过 提交于 2019-12-24 07:37:10
问题 I have this script // Prompting user to specify the domain and acting on domain system.stdout.writeLine('Enter the domain to test - "UAT1","UAT2","RC" or "LIVE" :'); var testingENV = system.stdin.readLine(); In addition there are other part of my test script which relies on user input system.stdout.writeLine('Enter your NRIC number :'); var NRICno = system.stdin.readLine(); system.stdout.writeLine('Enter your Mobile number in the follwing format (+6588888888) :'); var MOBno = system.stdin

--xunit output when running a directory of tests

旧巷老猫 提交于 2019-12-24 02:42:56
问题 There is a similar question here - Casperjs 1.1 does not generate XUnit xml file The answer to linked question works when one is executing single .js files, when I trigger the script with casperjs test /path/to/test/files, then multiple test suite files in the folder get executed in sequence, and when that happens the file name in --xunit parameter doesnt get written to. Is there any way to do this? 来源: https://stackoverflow.com/questions/29467310/xunit-output-when-running-a-directory-of

How to synchronous call child process in CasperJS?

风流意气都作罢 提交于 2019-12-24 01:27:59
问题 Code: var casper = require('casper').create({ waitTimeout: 120000, stepTimeout: 120000, verbose: true, logLevel: "debug" }); var process = require("child_process") var spawn = process.spawn casper.start('http://baidu.com') casper.then(function () { casper.echo(httpCall('baidu.com', 'GET')) }) function httpCall(url, method) { var para = ["-X", method, url] casper.log('curl with parameters: ' + para) var child = spawn("curl", para) var result = "abc" child.stdout.on("data", function (data) {

Downloading a file with CasperJS from POST attachment

南楼画角 提交于 2019-12-24 00:07:59
问题 I almost have this working, I just can't seem to download the file when it comes up. What am I doing wrong here? When clicking the button "Download Sales Report" a CSV should download, by my console.log() never even fires off. var casper = require('casper').create(); casper.start('http://www.waynecountyauditor.org/Reports.aspx?ActiveTab=Sales') .waitForText("Accept") .thenClick('#ctl00_ContentPlaceHolder1_btnDisclaimerAccept') .waitForText("View Sales") .thenClick('#ctl00_ContentPlaceHolder1

CasperJS “unable to load script”

时光总嘲笑我的痴心妄想 提交于 2019-12-23 22:32:25
问题 I have the strangest issue while writing a new script for casperJS, which I use all the time. When I try to launch the script, using "casperjs myScript.js, I get the following : Unable to load script /var/www/scrapers/myScript.js; check file syntax I checked my syntax and found nothing wrong, chmod +x the file, sudoed everything, still the same. Even stranger, I copypasted the example code from the quickstart (http://docs.casperjs.org/en/latest/quickstart.html), saved , and same message...

Setting radio button with Casperjs

╄→尐↘猪︶ㄣ 提交于 2019-12-23 18:41:16
问题 I'm trying without success to set the value of a radio button with CasperJS. Can somebody explain to me why the assertEval is failing on this test? this.test.assertExist('input[name=main][value=yes]'); casper.thenEvaluate(function(term) { document.querySelector('input[name=main][value=yes]').setAttribute('checked', true); }); this.test.assertEval(function() { return document.querySelector('input[name=main][value=yes]').getAttribute('checked') == "true"; }, 'Main was set to true'); 回答1: To