casperjs

Issues getting CasperJS to upload image to file field - tried CasperJS fill() and PhantomJS uploadFile()

房东的猫 提交于 2019-12-22 05:09:12
问题 I'm trying to use CasperJS to upload images to a web-form. My form looks something like this: <form action="" method="POST" enctype="multipart/form-data" class="form-vertical"> ... <legend>Campaign Banner</legend> <div class="control-group image-field "> <label class="control-label">Now Large</label> <div class="controls"> <div class="file-field"><input id="id_now_large_image" name="now_large_image" type="file"></div> <div class="image-preview"></div> <div class="clear"></div> <span class=

Using casperjs and phantomjs to scrape multiple pages

时光怂恿深爱的人放手 提交于 2019-12-22 01:41:01
问题 I'm trying to scrape a number of pages that have a standard format. I've been able to use Phantomjs to successfully scrape a single page, but when I try to iterate over multiple ones, the asynchronous processing makes things hang up. What's the proper way to tell Casper/Phantom to wait? var page = require('webpage').create(); var fs = require('fs'); page.onConsoleMessage = function(msg) { phantom.outputEncoding = "utf-8"; console.log(msg); }; // this overwrites the previous output file f = fs

CasperJS getting innerHTML of element by class

老子叫甜甜 提交于 2019-12-21 17:48:49
问题 I'm new to CasperJS and I'm having a few issues getting the innerHTML out of <p class="city">Data I Need</p> I have tried a few things, but nothing seems to get it. var city_name= casper.evaluate(".//*[@class='city_name']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; var friend_username = city_name.innerHTML; and var city_name = this.evaluate(function() { return document.querySelector(".//*[@class='city_name']").innerHtml; }); 回答1: CasperJS works by default

How to get Casper JS to return an exit code that indicates test success status?

你说的曾经没有我的故事 提交于 2019-12-21 13:07:09
问题 I want to be able to have a set of Casper JS tests and get an exit code back of 0 on success and non-zero on error or test failure (I want to run the casper command from java and determine if a test passed). The problem I am having is that an exit code of 0 is always returned. Here is an example test where this happens: var casper = require('casper').create(); casper.start('http://www.google.com', function() { this.test.assertEquals(true, casper.cli.options['value']); }); casper.run(function(

CasperJs + jenkins : when a test fails, how to retrieve all information on this test

徘徊边缘 提交于 2019-12-21 12:39:03
问题 Well , I would like to know how to get back the information of a test failed in jenkins. Here the result of my folder (fr) (it displays 22 min. but in parallel it's 3min) : Here the description of the test failed -jenkins- : Here the description of the test failed -casper- : So my problem is jenkins displays only the message of the test failed, and I would like to have also useful information as line and code (in fact there is the console output but it's not convenient-> I've changed my mine,

casperjs passing params to evaluate fails

我与影子孤独终老i 提交于 2019-12-21 07:56:34
问题 casper.then(function(){ phone_number = '7wqeqwe6'; phone_password = 'Teqweqweqw34'; }); casper.thenEvaluate(function(phone,password) { document.querySelector('input#myTMobile-phone').setAttribute('value',phone); document.querySelector('input#myTMobile-password').setAttribute('value',password); // document.querySelector('form').submit(); }, { phone : phone_number, password : phone_password }); this throws me string(307) "[37;41;1mFAIL[0m ReferenceError: Can't find variable: phone_number Is

Does CasperJs then() wait on emitted events in the previous function?

橙三吉。 提交于 2019-12-21 04:52:03
问题 I am just curious how CasperJS handles events with regards to the call stack. Let's say we have some code: casper.on('foo', function() { this.wait(60000); this.echo('foo'); }); casper.start('http://www.stackoverflow.com', function() { this.echo('start'); this.emit('foo'); }); casper.then(function() { this.echo('done'); }); casper.run(); I know that then() will wait check against 3 flags: pendingWait, loadInProgress, and navigationRequested. Printing out the call stack shows the emit call to

CasperJS: Configure proxy options inside code

拈花ヽ惹草 提交于 2019-12-20 15:33:49
问题 I was wondering how we could set cli parameters inside our code and not by placing them at the end of our command like this: casperjs casper_tor.js --proxy=127.0.0.1:9050 --proxy-type=socks5 I've tested things like that but it didn't work: var casper=require('casper').create(); casper.cli.options["proxy"] = "127.0.0.1:9050"; casper.cli.options["proxy-type"] = "socks5"; ... casper.run(); What I'm trying to achieve is to set new proxies inside my code and to scrap my new ip address from

PhantomJS/CasperJS site login, cookies are not accepted by PhantomJS

本小妞迷上赌 提交于 2019-12-20 10:07:11
问题 I recently tried to login into a webiste that forces me to accept cookies. I'm using phantomJs and casperJs. I wrote a little script that should handle the login, but it redirects me to a site that tells me I have to accept cookies. Email and password are just placeholders. The site I want to login is https://de.buyvip.com/ . But I need to click the button Anmelden mit Amazon so I can login with my amazon account. The other login form does not work. (That leads to this long url, I just copied

Frontend testing: what and how to test, and what tool to use?

倾然丶 夕夏残阳落幕 提交于 2019-12-20 07:59:15
问题 I have been writing tests for my Ruby code for a while, but as a frontend developer I am obviously interested in bring this into the code I write for my frontend code. There is quite a few different options which I have been playing around with: CasperJS Capybara & Rspec Jasmine Cucumber or just Rspec What are people using for testing? And further than that what do people test? Just JavaScript? Links? Forms? Hardcoded content? Any thoughts would be greatly appreciated. 回答1: I had the same