casperjs

waitForSelector passes, but assertExists fails for the same selector

主宰稳场 提交于 2019-11-28 14:04:36
When I call the following function, waitForSelector passes for 'selector', but assertExists fails for the same selector. How is it possible? casper.waitForSelector(selector, function() { casper.test.assertExists(selector, sectionName + " opened up successfully."); }, function() { casper.test.fail(sectionName + " did not load in given time"); }, max_timeout); Here is a complete example to reproduce the issue with an :nth-child selector. This is a known bug (see #11632 , #11737 ) in the Qt4 fork of WebKit (from 2010). It happens when :nth-child() or :nth-of-type() CSS3 selectors are used. The

CasperJS/ Javascript Selecting Multiple Options

巧了我就是萌 提交于 2019-11-28 13:51:24
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 looping Also the website I am trying to scrape says hold "shift" to select multiple elements but then it

How to properly hover the mouse over an element in PhantomJS/CasperJS

∥☆過路亽.° 提交于 2019-11-28 13:31:12
问题 In my opinion, a problem of getting dynamic content is really very ambiguous. I tried to find some useful information, used many different code examples, certainly modifying them to my purposes, but unfortunately, without any results( I need to get some contents from here. Try to explain detailed what are the problems i faced to (need to notice, that all i do is exclusively for my own use!). Main web site page has main navigation (Main nav pic) list with each list class "menu__category

How to change PhantomJS version

为君一笑 提交于 2019-11-28 13:23:25
问题 I am learning PhantomJS for scraping. I started to incorporate CasperJS. When I run CasperJS and the filename I get back CasperJS needs PhantomJS v1.x How do you change the PhantomJS version to use CasperJS? Is there an easier way to scrape a website that is heavy javascript? I used cheerio and require but they only get static html. 回答1: This message is shown if you try to use PhantomJS 2.x with a CasperJS version <= 1.1-beta. use different PhantomJS once If you also have PhantomJS 1.x on

Run phantomjs with --ignore-ssl-errors=true from casperjs

别说谁变了你拦得住时间么 提交于 2019-11-28 11:55:53
I have a problem with https page. Page is completly ok, it exist but phantomjs tell me something else: 'loading resource failed with status fail'. I read about it for a while and for now i know it's phantomjs bug and the solution to this problem is: --ignore-ssl-errors=true So I know solution, but don't how to use it. How can I pass this to phantomjs from casper? Where should I do that ? EDIT: Entire code: var casper = require('casper').create({ verbose: true, logLevel: 'warning', pageSettings: { javascriptEnabled: true }, viewportSize: {width: 1024, height: 768} }); var url = 'http://us3.php

How to fill a select element which is not embedded in a form with CasperJS?

对着背影说爱祢 提交于 2019-11-28 10:53:18
问题 My html code is: <div class="setting-control"> <select class="on-off" id="custom-cache-pref"> <option value="">Default</option> <option value="byc">Bypass cache</option> <option value="basic">Basic caching</option> <option value="iqs">Ignore query string</option> <option value="agg">Aggressive caching</option> <option value="all">Cache everything</option> </select> </div> Usually with casperjs I would use this.fillSelectors('form[name="formName"]', { 'select[id="custom-cache-pref"]': 'byc' },

How to pass a variable as an argument to a CasperJS script through the command line?

喜你入骨 提交于 2019-11-28 10:48:33
I'm using PhantomJs, CasperJs, and Js in a js file ran through the cmd. Imagine we had two files(test1.js, and test2.js). Both files have a url/site variable that directs the test to a particular address. Everytime an environment changed or the target location changed, we would need to update this variable. To avoid having to update the files, I'd like to pass the values through the command line, as to where to test this. Is there a way to declare the string variable through the cmd as you run the file? E.g.: casperjs test.js "var site='http://google.com';" kapa The documentation says you can

How to follow all links in CasperJS?

谁都会走 提交于 2019-11-28 10:23:00
I'm having trouble clicking all JavaScript based links in a DOM and saving the output. The links have the form <a id="html" href="javascript:void(0);" onclick="goToHtml();">HTML</a> the following code works great: var casper = require('casper').create(); var fs = require('fs'); var firstUrl = 'http://www.testurl.com/test.html'; var css_selector = '#jan_html'; casper.start(firstUrl); casper.thenClick(css_selector, function(){ console.log("whoop"); }); casper.waitFor(function check() { return this.getCurrentUrl() != firstUrl; }, function then() { console.log(this.getCurrentUrl()); var file_title

Why doesn't plain JavaScript work in CasperJS?

元气小坏坏 提交于 2019-11-28 10:22:06
问题 I'm new to CasperJS. How come this.echo(this.getTitle()); works but console.log("Page Title ", document.title); doesn't? Also why isn't my document.querySelector working? Does anyone have a good explanation? Where in the CasperJS documentation can I find the answer? Here's my code: var casper = require('casper').create(); var url = 'http://www.example.com/'; casper.start(url, function() { this.echo(this.getTitle()); // works this.echo(this.getCurrentUrl()); // works }); casper.then(function()

CasperJS script never exits

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 08:53:53
问题 My CasperJS script never stops executing. var casper = require('casper').create(); casper.userAgent('Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36'); casper.start('https://www.google.co.in/',function(){ casper.wait(3000,function(){ this.echo(this.getTitle()); }); }); casper.run(); 回答1: It only looks as if CasperJS never exits. This is only an issue on windows. You probably see something like this: C:\> casperjs script.js C:\> Some