casperjs

Running 'casperjs test' in phantom

倾然丶 夕夏残阳落幕 提交于 2019-12-18 07:04:52
问题 So I have a file running in node which runs a local copy of PhantomJS as below shows: phantom.casperPath = 'node_modules/casperjs'; phantom.injectJs('node_modules/casperjs/bin/bootstrap.js'); var casper = require('casper').create({ viewportSize: config.viewportSize }); casper.test.begin('Runing tests here', 5, function suite(test) { // Tests here }); Without the casper.test.begin() my tests function fine. I have the correct version 1.1.0 which can use this test suite but I get the following

Click on all links matching a selector

99封情书 提交于 2019-12-18 05:54:45
问题 I have a list of links that I have to simulate a click on using CasperJS. They all share the same class. However using this.click('.click-me') only clicks on the first link. What's the proper way of clicking on all the links? I'm thinking that maybe I should try to get the number of links via evaluate() and then use a for loop. But if I use evaluate() with the number of links I have to use messages to communicate back and that seems complicated. Is there a better way? 回答1: I ended up using

Automate daily csv file download from website button click

非 Y 不嫁゛ 提交于 2019-12-18 05:14:15
问题 I would like to automate the process of visiting a website, clicking a button, and saving the file. The only way to download the file on this site is to click a button. You can't navigate to the file using a url. I have been trying to use phantomjs and casperjs to automate this process, but haven't had any success. I recently tried to use brandon's solution here Grab the resource contents in CasperJS or PhantomJS Here is my code for that var fs = require('fs'); var cache = require('./cache');

CasperJS/ Javascript Selecting Multiple Options

微笑、不失礼 提交于 2019-12-17 21:31:08
问题 Trying to scrape a website, where this is the generic HTML code <select id="xxx" multiple name="zzz"> <option value="123">xaxaxa</option> <option value="124">zazaza</option> <option value="125">ajajaj</option> <option value="126">azzzsa</option> </select> It is not enclosed by a form so I tried using the fill() function that casperjs provides but that did not work. For single entries, I would usually casper.click() and that would work but this does not work for multiple entries even with

CasperJs and Jquery with chained Selects

删除回忆录丶 提交于 2019-12-17 16:54:13
问题 I'm trying to create a testing case for a web site which includes a form with 3 chained selects. The first select is populated by default when the web page is loaded. If any option from the first select is selected, then the second select is populated via an ajax call. In the same way, when an option is selected on the second selected, so the third select is populated via an ajax call. Finally, when an option is selected on the third select, a html table is populated with the information than

CasperJs and Jquery with chained Selects

↘锁芯ラ 提交于 2019-12-17 16:54:09
问题 I'm trying to create a testing case for a web site which includes a form with 3 chained selects. The first select is populated by default when the web page is loaded. If any option from the first select is selected, then the second select is populated via an ajax call. In the same way, when an option is selected on the second selected, so the third select is populated via an ajax call. Finally, when an option is selected on the third select, a html table is populated with the information than

Understanding the evaluate function in CasperJS

扶醉桌前 提交于 2019-12-17 09:45:29
问题 I want to understand in which case I should or have to use the evaluate function. I have read the API doc about the evaluate function of CasperJS, but I'm unsure in which case I should use this function. And what does DOM context mean? Can somebody provide an example? 回答1: The CasperJS documentation has a pretty good description of what casper.evaluate() does. To recap: You pass a function that will be executed in the DOM context (you can also call it the page context). You can pass some

not able to lazy load in phantomjs

烂漫一生 提交于 2019-12-14 04:19:10
问题 I'm trying to scrape some information from the link (http://www.myntra.com/women-sarees?nav_id=606) that involves lazy loading. Below is my code snippet for this: window.setInterval(function() { //var count returns the visibility of the div that checks for lazyloading if((count == 'none')) { // more products to be loaded page.evaluate(function() { // Scrolls to the bottom of page window.document.body.scrollTop = document.body.scrollHeight; }); page.render('myn'+k+'.png'); } else { // Found /

CasperJS/PhantomJS unable to open Facebook

三世轮回 提交于 2019-12-14 03:55:33
问题 I've seen examples such as this one showing how to login to facebook with casperJS: How to login into a website with CasperJS? but am unable to get this code to work for me. I'm not interested in the login portion, I just want to load any facebook page into casperjs or phantomjs but keep getting a fail on load. Is this working for anyone else? or has facebook detected the browser and not allowing access anymore? Here is a simplified version of what I am unable to do: var casper = require(

Which version of CasperJS is working well with PhantomJS?

时间秒杀一切 提交于 2019-12-13 21:44:49
问题 But the cases often occurred when each of us who new to CasperJS or Phantom.... they start to combine both latest version and try to execute the tutorial (from the old-out-dated resource) >> Result is... error on many parts. Thus, to overcome this matter. I wish there's some notes about both versions that workings well side-by-side. For instance casperJS 1.0.4 and phantomJS 1.8.2 >> not a good choice, because function of this.getElementsInfo() will not working well inside the code. 回答1: