casperjs

Casperjs and waitForUrl() to wait for next page

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:46:51
问题 I'd like to use the waitForUrl() function from http://docs.casperjs.org/en/latest/modules/casper.html#waitforurl . After a login form was send casperjs should wait for the next page is loaded. In the code below you see the "Second variant" that's the way I try to code this and you also see the occuring error message. The "First variant" is working so the dashboard.png is captured. Can someone explain what is wrong with the "Second variant"? // ... // Type and send login Form casper.then

Casper.js/Phantom.js not submitting data

匆匆过客 提交于 2019-12-25 04:22:23
问题 I'm using Casper.js to automate submitting a form. The form's onSubmit method returns false and runs some javascript (onclick callback) before sending the data, so I have to use clickLabel , instead of fill . The data is prepopulated, I just have to click the Submit button. When I use Casper to do clickLabel('Submit') , the data isn't submitted. What am I doing wrong? Edit - here's the markup of the label: <a class="green_btn white font_18 arrow_btn_pad rad_5" onclick="$.shactivity

CasperJS - Scraper not navigating to the next page

最后都变了- 提交于 2019-12-25 03:59:16
问题 The following code is a simple scraper written in CasperJS. var casper = require('casper').create(); var url = casper.cli.get(0); var page1 = casper.cli.get(1); var page2 = casper.cli.get(2); //console.log(page2); var proxy = casper.cli.get(3); //alert(page1); var exp = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi; var regex = new RegExp(exp); var baseUrl = url; //console.log(baseUrl); var nextBtn = "a.navigation-button.next"; var allLinks = []; casper

How do I set a variable from casper.evaluate()?

你离开我真会死。 提交于 2019-12-25 03:43:09
问题 I'm trying to set a value from within casper.evaluate() that I will check later to run a test on, but it doesn't seem to be working. isArticleOrReview = false; casper.waitFor(function check() { //here I'm just waiting for jQuery to load return this.evaluate(function() { return jQuery.fn.jquery == '1.2.6'; }); }, function then() { //once jQuery has been loaded, do this stuff this.evaluate(function() { isArticleOrReview = (jQuery('body').hasClass('node-type-review') || jQuery('body').hasClass(

casperjs check that title exists and has any value so test not empty

穿精又带淫゛_ 提交于 2019-12-25 02:38:51
问题 This seems like an easy question but I am new to casperjs. I want to check that title exists and that it has a value e.g. not ="". Also same for meta tags that they exist and also have been populated with something. I don't want a specific value just test they exist and not empty e.g. not ="". I thought this would be simple in casperjs 1.1 test suite Site: <head> <title>UnoSpark</title> <link rel="stylesheet" href="stylesheets/foundation.css"> <meta name="description" content="Free Dating

CasperJS cannot click on a DIV button

橙三吉。 提交于 2019-12-24 16:15:14
问题 I have been working on a website scraping project using CasperJS. It is an ASPX website. I could login to the site and then fill the form that runs a search but after filling the form I cannot simulate a click on the DIV button. The search runs using AJAX but when I capture page after waiting few seconds it does not show results in the captured image. The Search button is made of DIV and upon clicking it runs other hidden JavaScript functions that send the AJAX request to retrieve the search

How can I turn part of my casperjs script into a function so I can use it multiple times

Deadly 提交于 2019-12-24 15:27:31
问题 Okay, so here is a part of my casperjs script below which works fine if(casper.exists(ac1)){ var uel = "https://example.ws/send.html?f=1099817"; this.thenOpen(uel, function() { casper.wait(10000, function() { casper.then(function() { this.evaluate(function() { var amount = 0.29 var result = amount * 0.019 var result2 = result.toFixed(6); var fresult = amount - result2; var needed = fresult.toFixed(3); document.getElementById('account').value = 'ydfg028'; document.getElementsByName('data')[0]

Download img/png mime type , casperJS

こ雲淡風輕ζ 提交于 2019-12-24 14:27:32
问题 I'm having a casperJS script to trigger an image download on a button click. I have clicked the button, and the resouce.recived has a file of type image/png. How do I download that and save ? When I tried download(resource, "something.png); I get to download HTML(source code of the page) and not the desired image. Relevant segment of my code : var dFile = casper.on('page.resource.received', function(resource) { if (resource.stage !== "end") { return; } if(resource.contentType.indexOf('image')

How to use getElementByXpath and getElementsByXpath correctly?

六眼飞鱼酱① 提交于 2019-12-24 14:07:19
问题 How can I get table 'td' values with CasperJS? The HTML source looks like than this: <table id="my_table"> <tr id='header'> <th>sth_head_name</th> <th>ath_head_name</th> <th>sth_head_name</th> <th>sth_head_name</th> <th>sth_head_name</th> </tr> <tr> <td>sth_value</td> <td>sth_value</td> <td>sth_value</td> <td>sth_value</td> <td>sth_value</td> </tr> <tr> <td>sth_value</td> <td>sth_value</td> <td>sth_value</td> <td>sth_value</td> <td>sth_value</td> </tr> <tr> <td>sth_value</td> <td>sth_value<

Amazon Seller Central Login Scrape PhantomJS + CasperJS

会有一股神秘感。 提交于 2019-12-24 12:44:30
问题 I want to start off by saying that we only scrape our own account, because my company needs data from our own dashboard that we can't get from the MWS APIs. I am very familiar with those APIs. I've had login/scraping scripts for years. But recently Amazon started offering up captchas. My old way of scraping was from PHP making cURL requests to mimic the browser. My new approach is using PhantomJS and CasperJS to achieve the same effect. Everything was working fine for a day, but I'm getting