casperjs

JS Testing: Trigger jQuery keypress event from CasperJS and PhanthomJS

十年热恋 提交于 2020-01-01 19:42:14
问题 my webpage has a listener to the enter key press event. I am trying to run the casperjs code below to trigger this event, but without success. Although no error is prompted out, the (evaluate) function returns true and the code works fine from my chrome console, the function result, that should be sending a request to the server is never happening casper.then(function(){ var result = this.evaluate(function(term){ var search_form_id = "#search-form"; $(search_form_id).val(term); jQuery(search

Phantom.js / Casper.js with rotating proxy?

断了今生、忘了曾经 提交于 2020-01-01 09:25:10
问题 I have a simple goal: load webpages with either phantom.js (out of the box) or casper.js (nice and easier) but using proxy and rotate it from a list if current one is bad (i.e. webpage loads fail or something like that). I know casper.js has --proxy param but it dictates the user to specify only ONE proxy and use it during runtime. Question #1 is: how to rotate proxy on the fly programmatically? I did some research and found this node-requester but it's not integrated with casper.js . I tried

How to for loop in casperjs

拥有回忆 提交于 2020-01-01 05:37:24
问题 I am trying to click a 'next' button N number of times and grab the page source each time. I understand that I can run an arbitrary function on the remote website, so instead of click() I just use the remote function nextPage() How do I run the following, an arbitrary number of times: var casper = require('casper').create(); casper.start('http://www.example.com', function() { this.echo(this.getHTML()); this.echo('-------------------------'); var numTimes = 4, count = 2; casper.repeat(numTimes

CasperJS can not trigger twitter infinite scroll

天大地大妈咪最大 提交于 2020-01-01 05:12:11
问题 I am trying to get some information from twitter using CasperJS . And I'm stuck with infinite scroll. The thing is that even using jquery to scroll the page down nothings seems to work. Neither scrolling, neither triggering the exact event on window (smth like uiNearTheBottom) doesn't seem to help. Interesting thing - all of these attempts work when injecting JS code via js console in FF & Chrome. Here's the example code : casper.thenEvaluate(function(){ $(window).trigger('uiNearTheBottom');

CasperJS dynamic selectlists

不羁的心 提交于 2019-12-31 00:56:07
问题 Need help I am scraping data from this website which has a form that contains three selectlists interconnected to each other that is if the any option from the from the first select list is selected this function is called onchange="Javascript:submitForm2(); and the second selectlist is populated. And subsequently if an option from the second selectlist is selected the same js function is called onchange="Javascript:submitForm2();" And finally two submit buttons for this form each call

querySelectorAll not recognizing var

瘦欲@ 提交于 2019-12-30 13:58:22
问题 I am using casperjs for some webscraping and am having a strange problem. I want to be able to construct a CSS path from strings and get an array using 'querySelectorAll' like below: var tier = '-ou-'; var index = 'div.list > div > a[href*="' + tier + '"]'; var battles = document.querySelectorAll(index); However, this does not work, and battles returns null. This version works: var links = document.querySelectorAll('div.list > div > a[href*="-ou-"]'); But none other does. I also tried: var

CasperJS and 'Unsafe JavaScript attempt to access frame with URL' error

你离开我真会死。 提交于 2019-12-30 05:45:11
问题 I have simple page with javascript which validates email written in input: email.html: <!DOCTYPE html> <html> <head> <title>Email validation</title> <script src="email.js"></script> </head> <body> <span style="padding: 5px;"> <input type="text" id="email-input" placeholder="Email..."></input> </span> </body> </html> email.js: var checkEmail = function() { var regexp = /BIG_REGEX/; var email = document.getElementById('email-input').value; if (email === '') removeFrame(); else if (regexp.test

Output client-side console with casper/phantomjs

蓝咒 提交于 2019-12-30 03:44:16
问题 Going through the casperjs documentation I couldn't find where I could see the console.log from client-side javascript. Is this possible? 回答1: I'm not really sure to fully understand your question, but you can do something like the following: var casper = require('casper').create({ logLevel: "debug" }); casper.on('remote.message', function(message) { this.echo(message); }); casper.start('http://google.com/', function() { this.evaluate(function sendLog(log) { // you can access the log from

casperjs does not find phantomjs

早过忘川 提交于 2019-12-30 02:37:07
问题 I've downloaded the latest version of casperjs (1.03) and phantomjs (1.9.2). So I took this little simple script from the casper page: var casper = require('casper').create({ verbose: true, logLevel: "debug" }); var casper = new require('casper').Casper(); and when I try to run it I get the following error: noname:phantomjs-1.9.2 Tom$ casperjs/bin/casperjs tipico2.js Fatal: [Errno 2] No such file or directory; did you install phantomjs? So, this is my directory structure: phantomjs-1.9.2/ <--

How to tell CasperJS to loop through a series of pages

不问归期 提交于 2019-12-30 00:36:08
问题 I try to make CasperJS achieve the following: Go through a series of pages that are named sequentially by date. On each page, locate a PDF link. Download the PDF. I got some working code, but I don't understand how CasperJS is going through the sequence of events. For instance, in the code sample below, CasperJS tries to process step 2, and throws a "ReferenceError: Can't find variable: formDate", while step 1 isn't executed at all for some reason. What's wrong with my reasoning? It seems to