phantomjs

PhantomJS does not take arguments to function passed to page.evaluate()

帅比萌擦擦* 提交于 2019-12-22 04:50:15
问题 I can't pass arguments to function passed to page.evaluate . I am trying to submit form. data1 = "Textsample"; page.evaluate(function(data1) { var form = document.getElementById ("MyForm"); form.data.value = data1; form.submit(); }); But when I'am taking screenshot of page the data field is filled with "undefined". What am I doing wrong and how to fix it? 回答1: You need to pass it as 2nd arg in page.evaluate . page.evaluate(function(arg){},arg); 来源: https://stackoverflow.com/questions/28524130

ember tests passing in chrome, not in phantomjs

穿精又带淫゛_ 提交于 2019-12-22 04:34:08
问题 I have tests for an addon which pass in chrome, but fail in phantomjs. It seems to be a problem similar to this question. However, I tried the solution there and it didn't work for me. The code is all available in the public repo linked above. The failures are exhibited in the failing travis build on github. Any ideas on how to diagnose better and fix? EDIT -- actual error message Died on test #1 at http://localhost:7357/assets/test-support.js:3062 at test (http://localhost:7357/assets/test

How to test String.prototype.includes in PhantomJS

大城市里の小女人 提交于 2019-12-22 04:05:30
问题 I have an ember-cli 0.2.7 using Ember.js 1.12.0 app with a piece of code that looks like: controllers/cart.js import Ember from 'ember'; export default Ember.Controller.extend({ footwearInCart: Ember.computed('model.@each.category', function() { return this.get('model').any(product => product.get('category').includes('Footwear')); }) }); It goes through all the objects in the model and returns true if their category property has 'footwear' in it. I'm trying to test it like so: tests/unit

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

Use “window.onload” in phantomjs

◇◆丶佛笑我妖孽 提交于 2019-12-22 00:17:59
问题 I'm scraping data from AJAX-based pages using PhantomJS through the npm-phantom module. Sometimes the data isn't loaded yet when phantom starts DOM traversal. How to insert something like window.onload = function() { ... } into the page.evaluate ? It returns me a function, but not the data. var phantom = require('phantom'); exports.main = function (url, callback) { phantom.create(function (ph) { ph.createPage(function (page) { page.open(pref + url, function (status) { page.evaluate(function (

Call function PhantomJs

折月煮酒 提交于 2019-12-21 23:43:21
问题 I'm new in Java Script and i need help :) I want to call function ( set_calendar_date() ) and then get page innerHTML. <a onclick="set_calendar_date('1'); return false;" href="#"> <span> 26/02 We </span> PhantomJs code : page.open(url, function (status) { if (status !== 'success') { console.log('Unable to access network'); } else { var events = page.evaluate(function () { // here i want to call set_calendar_date(); return document.getElementById('fs').innerHTML; }); var file= require('fs');

Selenium + PhantomJS in Python 2.7, file upload

大城市里の小女人 提交于 2019-12-21 23:20:04
问题 I've been struggling with this function for a few hours now and I can't get it to work in any way shape or form. Assume my element location and image path are correct at all times. (Seriously, I've been going over this for the past 4 hours, it's not the element location and it's not the file path.) What I started with was a sendkeys to the input element. This gave no error but caused the script to hang for ever; it wouldn't get past it and no images were being uploaded. I literally tried

Can't launch PhantomJS with Python in Windows 7

不打扰是莪最后的温柔 提交于 2019-12-21 21:48:02
问题 I'm trying to use PhantomJS with Python in my Windows 7, but is not working! Here what i tried to do. First, i installed webdriver. In the following code Firefox opens normally, so i believe webdrive is correctly installed. from selenium import webdriver browser = webdriver.Firefox() browser.get('http://seleniumhq.org/') Then, i downloaded PhantomJS from the official website, unpacked it and put it in c:\Phantomjs. Then i added it in Environment Variables. Here what is in there: C:\Phantom

Only Courier-Fonts with Phantomjs 1.7/1.8/1.9, perhaps CSS specific

萝らか妹 提交于 2019-12-21 21:25:57
问题 Since updating to OpenSuse 12.2 I cannot use phantomjs (updated from 1.5 to Version 1.8.1 64bit) any longer to create screenshots. The problem is a missing font support for serif/sansserif fonts. Only a courier/monospace like font is used. Additionally phantomjs is really slow on rendering (5 seconds and more --> solved ). I tried to install packages like google-droid-fonts, free-ttf-fonts, bitstream-vera-fonts, freetype, font-config - but the only result are some other ugly fonts used. Does

How to pass browser parameter to Watir

蓝咒 提交于 2019-12-21 19:47:11
问题 I am using Ruby and am using the latest gem version of Watir. I plan to use headless browser such as PhantomJS. How can one pass paramater to the Phantom JS browser when it get executed. My purpose is so that Phantom JS do not need to load images. 回答1: As described on the PhantomJS command line page, there is an option to control the loading of images: --load-images=[true|false] load all inlined images (default is true). Also accepted: [yes|no]. During the initialization of a Watir::Browser,