casperjs

Use a select outside of a form with CasperJS

天大地大妈咪最大 提交于 2019-12-01 11:36:54
I want to select an entry into a select. How I can do that with CasperJS. Some information you need to know : I can't modify the page. My task is only to write the test. The select markup is not included in a form. I cannot use the document.querySelector(MY_SELECT).selectedIndex = X; method because changing the select (with normal behaviour) throw some event I need, and they are not thrown with simple affectation. Do you want to just simulate the normal behaviour? That's right in some issue manipulate the DOM isn't sufficient (the events are not thrown and so you can't send your form because

Run/Execute CasperJS script by clicking a button on webpage

纵饮孤独 提交于 2019-12-01 10:48:55
I have a casperJS script which returns a JSON when run on commandline. I want to have an arrangement such that 1) I create a webpage 2) On clicking a button on the webpage the casperJS scripts gets executed at the server side and post/return the result back to the webpage. How can i do the same. EDIT: I am invoking an AJAX process written in php on clicking the buttom. The php script contains echo exec('casperjs sample.js'); It returned nothing but on checking the webserver error log I got the error 'casperjs' is not recognized as an internal or external command, operable program or batch file

CasperJS waitForResource: how to get the resource i've waited for

巧了我就是萌 提交于 2019-12-01 10:36:39
问题 casper.test.begin('Test foo', 1, function suite(test) { casper.start("http://www.foo.com", function() { casper.waitForResource("bar", function(resource) { casper.echo(resource.url); }); }); casper.run(function() { test.done(); }); }); casper.echo returns www.foo.com resource (the one in casper.start ), not the one with "bar". How can I get the resource i've waited for with waitForResource ? 回答1: You actually waited for the "bar" resource. The problem is that resource inside the then callback

Use a select outside of a form with CasperJS

北城余情 提交于 2019-12-01 09:27:59
问题 I want to select an entry into a select. How I can do that with CasperJS. Some information you need to know : I can't modify the page. My task is only to write the test. The select markup is not included in a form. I cannot use the document.querySelector(MY_SELECT).selectedIndex = X; method because changing the select (with normal behaviour) throw some event I need, and they are not thrown with simple affectation. 回答1: Do you want to just simulate the normal behaviour? That's right in some

How to run casperJS script from php API

杀马特。学长 韩版系。学妹 提交于 2019-12-01 09:00:07
问题 I have a casperJS script which returns JSON when run via commandline. I want to make an API preferably in PHP which runs the script as in commandline (casperJS sample.js) and returns the JSON as result. 回答1: You can use php-casperjs library which is a simple wrapper for casperjs . 回答2: I think you can use php exec() function as shown below to do this echo exec("/home/user/casperjs/bin/casperjs /full/path/to/your_script.js"); 来源: https://stackoverflow.com/questions/18302267/how-to-run-casperjs

Can't require Underscore with CasperJS

强颜欢笑 提交于 2019-12-01 07:31:17
I'm using CasperJS to run automated frontend tests but have run in to an issue with using other npm modules in my tests. I'm aware of patchRequire however I believe that is only to be called outside of the test environment as the test runner patches require automatically. I did include it but the results were the same. It says it can't find the module. I have confirmed the underscore module is installed in node_modules in the projects root folder. Code 'use strict' _ = require 'underscore' testConfig = testPageUrl: '' testSearchTerm: 'the' config = _.extend testConfig, require 'common/config'

Permission denied when run casperjs in iron.io

浪尽此生 提交于 2019-12-01 07:26:49
问题 I'm testing casperjs in iron.io as this example https://github.com/iron-io/iron_worker_examples/blob/master/binary/casperjs/googlelinks.js but when iron_worker complete this task, it gives an error message ./run.sh: 2: ./run.sh: casperjs/bin/casperjs: Permission denied Any idea on how to fix this? Thanks 回答1: in run.sh: .. chmod +x casperjs/bin/casperjs .. 来源: https://stackoverflow.com/questions/18449084/permission-denied-when-run-casperjs-in-iron-io

Unsafe javascript attempt to access frame when installing casperjs through npm windows

妖精的绣舞 提交于 2019-12-01 06:10:44
I have installed casperjs and phantomjs on my windows machina via npm. However I get this issue. C:\>casperjs sample.js C:\>Unable to open file: sample.js Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///C:/Users/vini/AppData/Roaming/npm/node_modules/casperjs/bin/bootstrap.js. Domains, protocols and ports must match. Artjom B. This is a known issue with CasperJS and the 1.9.8 version of PhantomJS. It doesn't do anything and the errors are only printed during exit. They don't interfere with your script. There is a workaround and it was merged into

CasperJS Can't find variable $

岁酱吖の 提交于 2019-12-01 05:42:10
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 fridges var fridges = $('a[href^="/fridges/"]'); this.test.assert(fridges.length == 3, 'More or less than 3

Python Subprocess returns non-zero exit status only in cron

自闭症网瘾萝莉.ら 提交于 2019-12-01 05:39:47
I have a Python script that manages a series of CasperJS tasks and processes the result. It runs well from the command line, but when I run the script in cron, I get the error: CalledProcessError: Command '['/path/to/casperjs', '/path/to/doSomething.js', 'args']' returned non-zero exit status 1 In Python, I call CasperJS: response = subprocess.check_output(['/path/to/casperjs', '/path/to/doSomething.js', 'args'], shell=True) I have tried shell=False and Popen as well, but I get the same result. I also tried making the entire command a string (instead of list), but that didn't help either.