FAQ Database Discussion Community


Proxying casperjs / phantomjs through Charles

ssl,proxy,phantomjs,casperjs,charles
I'd like to use casperjs / phantomjs to autofill some web forms. In order to debug my casperjs scripts, I'd like to use the (wonderful) Charles Web Proxy as a man-in-the-middle SSL Proxy, but haven't figured out how to make that work in casperjs / phantomjs. What works I've enabled...

ANT task for calling Karma/Jasmine

javascript,angularjs,ant,phantomjs,karma-jasmine
While searching the internet it seems that Grunt is the preferred task runner for executing AngularJS test under Karma/Jasmine. Our project has server side java code and browser side javascript code. We already have a full unit test suite for the Java code, which we use ANT to run this...

enable cookies in Phantomjs + selenium

python,cookies,selenium-webdriver,phantomjs
I want to login in amazons3 (with the url:'https://console.aws.amazon.com/iam/home?#security_credential') on my armv7 board.I used phantom2.0.1 from here and selenium2.45.0. I can open the website successfully, but when I doing 'submit' after filling the username and password, the website jump to an error page which shows ‘Please Enable Cookies to Continue’....

Can't install phantojm on server

phantomjs
I'm having a difficult time getting phantomjs installed on my server. I haven't found very good directions anywhere and the best I've found give me errors when I try to complete them. As of now I'm following these steps and getting these errors. Successfully used putty to login as root...

PhantomJS javascript wait until function complete

javascript,asynchronous,phantomjs,wait
I have a problem with a PhantomJS script. The script gets a JSON encoded string from a web page and does other things with it. The script: var address = address; var amount = 0; function changeAmount() { var page=require('webpage').create(); page.open (address, function(){ //parse json, set amount to something (usually...

PhantomJS fonts kerning issue

fonts,centos,phantomjs,kerning
Certain fonts letter spacing are mostly not symmetric - even have no gaps at all in some cases. The Server is "CentOS Linux release 7.0" (Had an older server version and this version gives better results but still not a good one) phantomjs version is 1.9.8 The html that I...

PhantomJS load same page multiple times does not work, cannot clear cache

java,selenium-webdriver,phantomjs,load-testing
I am trying to use PhantomJS for load testing website, but I am facing this problem, PhantomJS just loads website once, after that it does not actually hit it, I see that there are many discussion for people asking this feature for load testing purpose but looks like its not...

CasperJS/SpookyJS css selector is existing and not-existing

javascript,css-selectors,web-scraping,phantomjs,spookyjs
I have a strange problem during screen scraping with spookyjs / capserjs. I want to catch information from the following website: 'https://www.rwe-smarthome.de/is-bin/INTERSHOP.enfinity/WFS/RWEEffizienz-SmartHome-Site/de_DE/-/EUR/ViewApplication-DisplayWelcomePage'. Because the site contains more than one page of products I want to open the other sites too. Normally one could use this.click(selector, function() {}); to achieve this....

Phanomjs not properly capturing screenshot of a web page

javascript,node.js,pdf,phantomjs,webpage-rendering
I am testing phantomjs for creating screenshots from a web page at my local end. This is how HTML is rendering in localhost - Output But on creating pdf from code, width is not setting properly in PDF, ie some text gets cut as shown below. Following is the code...

PhantomJS pass argument to evaluate

javascript,node.js,phantomjs,nightmare
I have a small test app using mightmarejs as a wrapper for phantomjs I want to test for the existence of a class on an element. I have this code: new Nightmare() .goto(baseURL) .evaluate(function() { return document.querySelector('body'); }, function(element) { element.className.should.equal(expected) callback(); }) .run(); How can I pass an argument...

Accessing a form with Splinter + PhantomJS (Python)

python,selenium-webdriver,phantomjs,splinter
I'm trying to fill in the username and password box on this site: http://www.youwager.eu/welcome/ Here's the relevent html: <input type="text" class="form-control" name="customerid" id="customerid" placeholder="Account Number"> A simple browser.fill('customerid', login) works when using firefox, but I can't get phantomJS to interact with the element. It throws the following error: <class 'selenium.common.exceptions.InvalidElementStateException'>...

Phantomjs Automation of a website leads me to getting IP blocked

phantomjs
I'm using PhantomJS to automate a page. What I do is: do{ console.log(i); i++; page.open(url); do { phantom.page.sendEvent('mousemove'); } while (page.loading); if(page.injectJs('./Search.js') == false){ console.log("Search.js Failed") } var links = page.evaluate(function(json){ return search(json) },json) console.log(links); } while(links == "") So this leads me to opening the website repeated until what...

How to use phantomjs to take screen shot with dynamic data visualization

javascript,phantomjs,screenshot
When I follow this tutorial (http://phantomjs.org/screen-capture.html) to do a screen capturing, I got some problem about dynamic data visualization. In that tutorial, it uses some code like: var page = require('webpage').create(); page.open('http://localhost:8080/index.html', function() { page.render('screenshot.png'); phantom.exit(); }); But this seems work only with static page. I wonder if I have...

Testing an MP3 with PhantomJS

javascript,phantomjs,mp3
I want to set up a testing routine in Phantom that scans a podcast RSS feed, grabs the URLs of MP3 files, then tests to see that they exist. I have this: /* For checking one mp3 file */ function checkFile(url) { var fs = require('fs'); if (fs.exists(url)) { console.log('"'+url+'"...

node-horseman async not working?

node.js,asynchronous,phantomjs
I'm using node-horseman to ( hopefully ) allow me to carry out asynchronous phantomjs operations to achieve async headless browsing. The numbers in the array are at this stage irrelevant, I've just stripped the code down to the bare minimum to demonstrate the problem I'm having. When I run the...

setTimeout in Phantom.js

javascript,node.js,meteor,phantomjs
The code below wants Phantom.js to load the page, click on a button and wait for 5 seconds before returning the page's HTML code. Problem: However using setTimeout() to create the 5 seconds delay causes the page.evaluate function to return null to the callback function instead of the HTML. myUrl...

How do I use phantomjs uploadFile with Capybara and poltergeist?

capybara,phantomjs,poltergeist
I am trying to attach a file in my spec, but the capybara attach_file method does not work for me in poltergeist (it returns true but nothing gets attached). It does work in Selenium, but for other reasons I want to use poltergeist. I know that the phantomjs uploadFile method...

How to install PhantomJS v2 with npm

node.js,github,npm,phantomjs
I'm trying to install PhantomJS v2.0.0 using npm and after trying a couple of methods I've not found a working solution... On NPM the latest version is 1.9.16, so I've tried the following in my package.json: "phantomjs": "https://github.com/ariya/phantomjs/archive/2.0.0.tar.gz" This gives me an error because there isn't a package.json for this...

Phantomjs javascript inheritance misunderstanding

javascript,inheritance,phantomjs
I have following files: run.js (to run whole script) animal.js (parent abstract class for cat) animal/cat.js (child class for animal, on which I want to invoke methods) run.js var cat = require('./animal/cat').create('Tom'); console.log( cat.petName ); console.log( cat.paws ); cat.voice(); animal.js function animal(){ this.paws = 4; } exports.create = function(){ return...

Using phantomjs print proxy it used to access website

python,proxy,phantomjs
can someone point me in the right direction. Just need some documentation. I manually input a proxy, but I think it might be by passing it. I want to test my script to see if its actually going through my proxy with phantom. It looks like I successfully went through...

Phantomjs integrating waitfor with includeJs

javascript,jquery,phantomjs
I'm able to use the waitfor function that is provided in the examples https://github.com/ariya/phantomjs/blob/master/examples/waitfor.js I'm also able to use the includeJs provided here http://phantomjs.org/page-automation.html I'm having a hard time figuring out how to include the jquery with the waitfor function. The sudo code below is just one of the many...

Anyone successfully used jonnyw's “php phantomjs” with laravel, in a ubuntu envirement?

php,ubuntu,laravel,phantomjs
Anyone sucessfully used jonnyw's "php phantomjs" with laravel, in a ubuntu envirement? I do not know if I am doing anything wrong, but I am questioning if it would be possible that it is not possible to use it with laravel in linux... I get all the time "Error when...

Having trouble getting page.injectJs() to work in PhantomJS

javascript,node.js,phantomjs,headless-browser
I have the following in my code: phantom.createPage(function(page){ page.onCallback = function(data) { console.log("ph callback: ", data); }; page.open(req.query.testUrl, function(status){ if(status !== 'success'){ page.close(); res.status(500) .send('Page "' + testUrl + '" could not be loaded.') .end(); return; } var result = page.injectJs('lib/my-test-script.js'); console.log('injectJS: ', result); page.evaluate(function(){ window.callPhantom(window.mocha.constructor.name); }, function(){ console.log('finished'); page.close();...

PhantomJS --debug to file

selenium-webdriver,phantomjs
Debugging an issue with PhantomJS.. I added the command line param --debug=true and now I'm swamped by an ocean of debug messages but only on the console. Is there a param to direct the debug output to file? I tried output redirection but that didn't work oddly enough.....

Which XPath version is supported in PhantomJS?

selenium,xpath,phantomjs,version,ghostdriver
I'm using Selenium with PhantomJS. How can I find out which version of XPath is used in PhantomJS?

Casper JS: TypeError: 'null' is not an object

javascript,null,phantomjs,typeerror,casperjs
I am trying to grab the "David Welsh" text on this page: http://foster.uw.edu/faculty-research/directory/david-welsh/ When I do document.getElementById('Boundless').children[0].children[2].children[0].children[1].children[0].innerHTML in the browser console, I successfully select the text I want, but when I run my js file in Terminal, I get the error: TypeError: 'null' is not an object (evaluating 'document.getElementById('Boundless').children') Why...

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

javascript,phantomjs,casperjs
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...

Can't load json from url with Casper Js -> “Loading resource failed with status=fail”

javascript,json,get,phantomjs,casperjs
I am new to casper js and I would like to retrieve a json object from a get request. The message I get is the following : Loading resource failed with status=fail: https://api.twitter.com/1.1/search/tweets.json?q=casperjs Here is my code : var casper = require('casper').create({ verbose: true, logLevel: 'debug', pageSettings: { loadImages: false,...

Not possible to trigger GWT listbox ChangeHandler using CasperJS

javascript,gwt,phantomjs,casperjs
I'm writing tests using CasperJS for legacy GWT (2.3) code. I can change the selected value of a ListBox. document.querySelector('#id_of_select').selectedIndex = 1; But this does not trigger the onChange() method of a change handler on the ListBox. I have tried manually dispatching a change event on the select element (jquery...

find element by css property that is not explicitly set

javascript,css-selectors,phantomjs,karma-jasmine
In order to disable chrome autofill I have added invisible user/password fields to my input forms: <!-- fake fields are a workaround for chrome autofill getting the wrong fields --> <input style="display:none" type="text" name="fakeusernameremembered"/> <input style="display:none" type="password" name="fakepasswordremembered"/> The problem is that this breaks tests like: expect(element.find('input').length).toBe(10); There are 12...

Scrolling with phantomJs Selenium

java,selenium,selenium-webdriver,phantomjs
I am trying to get this particular code running for scrolling a webpage which is a type of pagination. It works like a charm with the Firefox driver, but when i use phantomJS it doesn't work and goes into infinite loop public class Drivers { public WebDriver phJS() { File...

Rails + AngularJS + Prerender.io (local server) setup not rendering pages

ruby-on-rails,angularjs,phantomjs,single-page-application,prerender
I am trying to setup Prerender.io server locally. I am Rails + AngularJs app. Already pulled prerender repo and started the server with node. $ export PORT=3001 $ node server.js 2015-03-13T08:15:48.152Z starting worker thread #0 2015-03-13T08:15:48.159Z starting worker thread #1 2015-03-13T08:15:48.161Z starting worker thread #2 2015-03-13T08:15:48.163Z starting worker thread #3...

Phantomjs does not open web page

javascript,testing,phantomjs,casperjs
I have started testing campus2020 site with casperjs (1.1.0-beta3) + phantomjs (1.9.8). And faced with the problem that site is not opening but instead tests just freeze. I have taken script example from phantomjs site: var page = require('webpage').create(); page.open('http://informatik.uni-leipzig.de/campus2020', function(status) { console.log("Status: " + status); if(status === "success") {...

page.evaluate - how to write to file inside of it?

javascript,phantomjs
How I can write result inside page.evaluate to file? This code works fine when putting results into console.log, but writing to file, using ts raising errors. page.evaluate(function(url) { function getHTTPResponseString(url, callback) { try { var xhr = new XMLHttpRequest(); xhr.onload = function() { if (this.status == 200) { var u8...

How to use DOMParser in PhantomJS?

javascript,dom,phantomjs
The following snippet works correctly and returns a Document node in Firefox, Chrome and Safari web consoles. However, it returns null in PhantomJS 1.9.8. (new DOMParser()).parseFromString("<div></div>", "text/html"); Any idea why this is returning null? ...

PhantomJS Process doesn't exit

java,selenium,phantomjs
I am creating several instances of PhantomJSDriver and can make requests to websites and get the data I want. Each instance is spawned via the following: WebDriver driver = BrowserUtils.getInstance().getBrowser(); When I'm done I attempt to do the following: driver.close(); driver.quit(); driver = null; However, if I open up a...

Using $.ajaxStop() to determine when page is finished loading in CasperJS

javascript,jquery,ajax,phantomjs,casperjs
So far in my tests written in CasperJS, I've been using waitForSelector() on page-specific elements to determine if a page has fully loaded (including all the async ajax requests). I was hoping to come up with a more standard way of waiting for page load and was wondering if the...

Cannot find module 'webpage' when using PhantomJS in MeteorJS

node.js,meteor,phantomjs
I'm using the phantom npm package via meteorhacks:npm package. However when running the basic Phantomjs example under Meteor.js I'm getting the Cannot find 'webpage' error. Why is this happening? Code var phantomjs = Meteor.npmRequire('phantom') var page = Npm.require('webpage').create(); page.open('http://github.com/', function() { console.log('Page Loaded'); phantom.exit(); }); Error W20150305-02:16:51.629(-5)? (STDERR) Error: Cannot...

phantomjs --web-security=no

security,phantomjs,casperjs
In the documentation for phantomjs, there is an option to turn off web security and allow XHR (cross domain requests). Does this present a security risk to a user if you are filling forms with credentials such as usernames and passwords and then downloading screenshots with casper/phantom?...

Karma not starting phantomJs

angularjs,node.js,phantomjs,gulp,karma-runner
I'm loosing my mind here. I have a gulp task that looks like this. var gulp = require("gulp"); var karma = require("karma").server; gulp.task("test", function (done) { karma.start({ configFile: __dirname + "/karma.conf.js", action:"run" }, function () { done(); }); }); My karma.conf.js looks like this: module.exports = function (config) { config.set({...

PhantomJS performing a search and grabbing the URL

javascript,phantomjs
The aim for my PhantomJS script is to load a specific website, find the search input element, write text in that input and perform the search. From the page loaded containing the search results I just want to grab the whole URL - it will contain the search parameters. After...

PHP in Javascript for PhantomJS + Highcharts

javascript,php,highcharts,phantomjs
I have just configured phantomjs which is working fine. I have it installed in order to create charts from highcharts and include them in automated email through cronjobs, based on user's info. This will be done in php and right now I have the execution running perfectly. My php is:...

Pass complete code to phantomjs

go,phantomjs,exec
I'm writing a service in Go and I'm using phantomJS to generate an image from a given url. From my Go program, I'm using Exec to start the phantomJS binary. This works fine, but now I'm looking for a way to pass the complete code, together with the call which...

PhantomJS not mimicking browser behavior when looking at YouTube videos

javascript,phantomjs
I posted this question to the PhantomJS mailing list a week ago, but have gotten no response. Hoping for better luck here... I've been trying to use PhantomJS to scrape information from YouTube, but haven't been able to get it working. Consider a YouTube video embedded into a web page...

How can PhantomJS communicate through RabbitMQ?

rabbitmq,phantomjs
I am new to RabbitMQ. I work with PhantomJS and use JavaScript to do stuff. Now, I need to send some of my results to the RabbitMQ in order to read them using another script. I mean, I want PhantomJS to communicate with RabbitMQ. To send some messages and to...

Success compilation of phantomjs on Raspberry 2 but not executing (libjpeg.so.8)

compilation,phantomjs,raspbian,libjpeg,raspberry-pi2
In my raspberry 2 with updated version of OSMC I would like to use PhantomJS with selenium in python and tried to compile it. Following this link: How to compile phantomjs on the raspberry pi 2 And this link: Adding swap for the raspberry pi Created swap file of 16Gb...

phantomjs image width not getting as expected

javascript,phantomjs,screenshot,viewport,browser-width
when i take screenshots using phanomjs using the following code works fine and I am getting width as 1920px and height is not a problem for me. var webPage = require('webpage'); var page = webPage.create(); page.viewportSize = { width: 1920, height: 1080 }; page.open("http://www.google.com", function start(status) { page.render('google_home.png'); phantom.exit(); but,...

Error during WebSocket handshake: location mismatch: wss://* != ws://*

amazon-web-services,meteor,websocket,phantomjs
when i run MeteorJS(1.1.0.2) test in PhantomJS(1.9.8) get this error msg in Amazone AWS Error during WebSocket handshake: location mismatch: wss://ddp--5539-torrentz.meteor.com/sockjs/102/chvlh52p/websocket != ws://ddp--5539-torrentz.meteor.com/sockjs/102/chvlh52p/websocket & this prevent all MeteorJS Mongo DB operations...

PhantomJS console charset

node.js,character-encoding,web-crawler,phantomjs
I'm trying to run below code but my console prints weird charset. var page = require('webpage').create(); var url = "http://www.bdtong.co.kr/index.php?c_category=C02" //var url = "http://www.baemin.com/"; /* var option = { encoding : "euc-kr" } */ page.onConsoleMessage = function(msg, line, source) { //phantom.outputEncoding = "utf8"; console.log('console> '+msg); }; page.open(url, function() { page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js",...

How can I see the HTTP status code from the request made by page.open?

phantomjs
I have a phantomJS script that contains the following: page.open(url, function (status) { if (status === "fail") { /* handle failure */ } }); The status check works sometimes, but the status will still be "success" even if the request returns 500. How can I get the actual request status...

Unsafe JavaScript attempt to access in capserjs [duplicate]

phantomjs,casperjs
This question already has an answer here: Using PhantomJS to embed all images of a webpage produces warnings but works 1 answer On each test run of casperjs test, the output closes with the following: Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///usr/lib/node_modules/casperjs/bin/bootstrap.js....

Don't have enough memory to build phantom.js - what to do?

linux,gcc,build,phantomjs
I am trying to compile phantom.js on VPS server (1Gb RAM). Build process generates an error (persistently): obj/svg/SVGAllInOne.o svg/SVGAllInOne.cpp {standard input}: Assembler messages: {standard input}:168320: Warning: end of file not at end of a line; newline inserted {standard input}: Error: open CFI at the end of file; missing .cfi_endproc directive...

Node.js cluster module doesn't release socket/port on http.Server.close()

javascript,node.js,sockets,phantomjs
In a Node.js script, I'm trying to open some ports/sockets and then close them again. I'm running into trouble when using Node.js Cluster module. It doesn't seem to close ports in the same way the same code does when not using the Cluster module. For example, take the following code...

karma.conf.js automatic file ordering?

angularjs,jasmine,phantomjs,karma-runner,karma-jasmine
I have a large angularjs project ordered by features. I'd like to setup unit testing but I'm having trouble getting the karma.conf.js file ordering setup. I tried specifying a simple glob pattern like **/*.js but many of my modules failed to load due to the ordering that they're included in...

Nightmare, PhantomJS and extracting page data

node.js,phantomjs,nightmare
I'm new to Nightmare/PhantomJS and am struggling to get a simple inventory of all the tags on a given page. I'm running on Ubuntu 14.04 after building PhantomJS from source and installing NodeJS, Nightmare and so forth manually, and other functions seem to be working as I expect. Here's the...

PhantomJSDriver found Element but is still undefined

java,selenium-webdriver,phantomjs
I'm having a weird issue with PhantomJSDriver and Java, I'm trying to click on a link like this : WebElement loginButton = wait.until( ExpectedConditions.elementToBeClickable(By.xpath("//a[@ui-sref='login']")) ); LOG.debug("Login Button Found : ["+loginButton.getAttribute("href")+"]" ); loginButton.click(); With Crome Driver I'm not having any issue, but with phantomsJS (2.0.0 (or 1.9.7/1.9.8) and GhostDriver 1.2.0 I'm...

How to unit test javascript function that calls getJSON

javascript,unit-testing,phantomjs,getjson,qunit
I've been struggling with unit test for 2 days now and there is something I can't achieve regarding async test. I'm new to unit test and I don't understand why this doesn't work. I have a file login.js that calls a $.getJSON(url, data, function) and returns a string with the...

Problems installing ember-cli using npm on c9.io IDE

node.js,phantomjs,ember-cli,cloud9-ide
I am trying to install phantom-js on a c9.io virtual machine / cloud IDE and I get the following error: $ sudo -s npm install --global ember-cli ... 0 info it worked if it ends with ok 28 info install [email protected] into /nix/store/a5ibcbcsm473kdr75kj4gpsr28ndnknp-nodejs-0.10.26/lib 29 info installOne [email protected] 30 info /nix/store/a5ibcbcsm473kdr75kj4gpsr28ndnknp-nodejs-0.10.26/lib/node_modules/phantomjs...

Phantomjs connection to Facebook fails SSL handshake [duplicate]

javascript,facebook,ssl,phantomjs
This question already has an answer here: PhantomJS failing to open HTTPS site 7 answers I am trying to build a web scraper for Facebook using phantomjs. The connection fails due to SSL handshake failure. I get the same result for twitter, but google works fine. Does anyone know...

I dont know how to add Proxy to my Phantomjs script

python,proxy,phantomjs,casperjs
I've been having issues accessing websites and just realized that since the websites are controlled by my company I need to add a step in my script that shows the webpage I have my companies proxy IP or Im on their server. I hope that makes sense. For example if...

pass HTML to phantom and render it to PDF

node.js,pdf,phantomjs
Normally in phantom you would be able to do something like this: phantom = require('phantom') phantom.create(function(ph){ ph.createPage(function(page) { page.open("http://www.google.com", function(status) { page.render('google.pdf', function(){ console.log('Page Rendered'); ph.exit(); }); }); }); }); However instead of loading a webpage i already have some html i want to pass and render as a PDF....

Is there a way to listen to an event in the phantom context from page context?

javascript,events,phantomjs,hook,webpage
For example: I open a page with PhantomJS, evaluate an asynchronous script (e.g. ajax). When it succeeds, I want to let the phantom context (outside of page.evaluate()) know that the asynchronous process is finished. I don't want to use setTimeout and setInteval to wait and check continously in the phantom...

Unable to click in CasperJS

javascript,web-crawler,phantomjs,casperjs
I want to crawl the HTML data. And, I tried headless browser in CasperJS. But, Can't able to click. - The following is tried code in CapserJS. var casper = require('casper').create(); var mouse = require('mouse').create(casper); casper.start('http://sts.kma.go.kr/jsp/home/contents/climateData/smart/smartStatisticsSearch.do', function() { this.echo('START'); }); casper.then(function() { this.capture("1.png"); this.mouse.click('li[class="item1"]'); casper.wait(5000, function() { this.capture("2.png"); }); });...

Connecting to proxy/VPN via phantomjs

proxy,phantomjs,vpn
I'm trying to connect to a VPN via phantomjs. It does not seem to work when I render a page it is blank this is the command: phantomjs --proxy-type=http --proxy=83.170.84.216 --proxy-auth=freevpnaccess.com:3071 test.js What am I doing wrong?...

How to handle browser prompts in CasperJS

javascript,phantomjs,casperjs,prompt
The scenario is, when I click a button browser would show an alert which accepts user input field with OK and cancel buttons. Now please tell me how to handle this type of alert. As we know CasperJS doesn't displays the alert windows. This is the casperJS code casper.then(function ()...

Setup PhantomJS from JSON using WebDriver in Java

java,selenium-webdriver,phantomjs
When running plain PhantomJS a config.json can be set which sets some options. How I can setup PhantomJS with JSON file when using the Selenium WebDriver? I have this: DesiredCapabilities caps = new DesiredCapabilities(); caps.setJavascriptEnabled(true); caps.setCapability("takesScreenshot", false); caps.setCapability( PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "/usr/local/bin/phantomjs"); driver = new PhantomJSDriver(caps); ...

How to click on a close button of a modal dialog with PhantomJS and GhostDriver

java,javascript,selenium-webdriver,phantomjs,ghostdriver
I'm trying to take a screenshot of some twitter pages with Java, PhantomJS and GhostDriver, but all the time I'm getting screenshots with modal dialogs (sign-up modal or cockies modal). Can somene suggest me how to find this close button and click it? There is no class or id directly...

Backbone.Deferred.Model: Why the unittest is not run?

backbone.js,coffeescript,phantomjs,mocha,chai
Here is the code in question. define (require) -> Backbone = require 'backbone' require 'backbone-deferred' class Data extends Backbone.Deferred.Model urlRoot: 'data' parse: (resp) -> resp.record or resp isValid: -> @get 'valid' # Newly introduced dataUrl: -> @get('data_url')?.replace /abc/, '' And here is the unit test define (require) -> Data =...

Page.render() returns false

java,javascript,selenium-webdriver,phantomjs,remotewebdriver
I'm using phantomjs for taking screenshots of several webpages. To get a screenshot image i have used the following code. var page = require('webpage').create(); page.viewportSize = { width: 1200,height: 800}; page.open('http://<randomwebpageAddress>', function(status) { console.log(status); console.log(page.render('screenshot.png')); phantom.exit(); }); but the result for some page is status = "success" but page.render returns...

Which version of PhantomJS is compatible with yslow?

phantomjs,yslow
I am stuck at this point where I see yslow is no more going for PhantomJS 2.0 as phantom.args property in API is deprecated. But in earlier version it works. Please let me know which version of PhantomJS works with yslow?...

Is it possible to convert HTML to PDF at client side using PhantomJS?

pdf,phantomjs
I am currently evaluating different libraries for HTML to PDF export. Some of them do implement HTML to PDF conversion, but it is labeled as experimental. PhantomJS sounds like a solid option, but I don't know for sure if it will be possible to generate the PDF at client side...

Does phantomjs regularly clear its cache automatically?

phantomjs,browser-cache
I need to change the default time of automatic cache clear for Phantomjs if there is such a feature. Any idea?

How to print CasperJS debugging results to text file

javascript,python,debugging,phantomjs,casperjs
I can't read the debugging issues in the command prompt. Can I send that to a text file in my PhantomJS or CasperJS scripts? Here is my python code; import os import subprocess #proxies = {'https': 'http://wmhproxy2:8080'} APP_ROOT = os.path.dirname(os.path.realpath(__file__)) CASPER = "C:/casperjs/bin/casperjs" #SCRIPT = os.path.join(APP_ROOT,'unicorn.js') SCRIPT = os.path.join(APP_ROOT,'unicorn.js') params...

PhantomJS WebDriver timeout (access via Selenium Grid)

selenium,selenium-webdriver,phantomjs,selenium-grid
I need to set (descrease) PhantomJS timeout: 300000 (300sec) -> 30000 (30sec) I have Selenium Grid with attached PhantomJS as WebDriver. PhantoimJS exec command: phantomjs --config=phantomjs.json --webdriver=6661 --webdriver-selenium-grid-hub=http://127.0.0.1:4440 Content of phantomjs.json (i add random values for test): { "resourceTimeout": 123456, "timeout": 345678, "wait": 234567 } But in Selenium grid shows...

Phantomjs disable javascript in page but enable included javascript

javascript,phantomjs
I am using phantomjs to retrieve CSS information from a page without execute its javascript. For example here is the code snippet. page.settings.javascriptEnabled = false; page.open('file:///home/sample.html', function(status) { if (status !== 'success') { console.log('Unable to access network'); } else { page.includeJs("file:///home/sample.js", function() { var class = page.evaluate(function() { return document.querySelector('body').className;...

Visit pages using PhantomJS directly when writing specs with TeaSpoon - Jasmine

javascript,ruby-on-rails,phantomjs,specs,teaspoon
I'm trying to write a Javascript spec for my Rails 3.2 application using Teaspoon (the Jasmine version). I'm trying to write a spec that does something like this describe("Fun", function() { var page = require('webpage').create() //ERROR it("should be so much fun", function() { page.open('/pageToTest/') expect($('#HereIsTheParty')).not.toBe( undefined ); }); }); However,...

Scraping an infinite scroll page stops without scrolling

javascript,phantomjs,casperjs
I am currently working with PhantomJS and CasperJS to scrape for links in a website. The site uses javascript to dynamically load results. The below snippet however is not getting me all the results the page contains. What I need is to scroll down to the bottom of the page,...

phantomjs not honouring box-sizing

css,phantomjs,yui-pure-css
I'm using phantomjs (1.9.8) to get screenshots for a project. This project uses Pure CSS grids for responsive layout. Here is a stripped down HTML demo for what I'm doing: http://output.jsbin.com/sobabiy/1 This is what phantomjs sees (viewport 1024x768): I'm a little rusty on my CSS skills, but my gut feeling...

Protractor with phantomjs hangs forever

angularjs,windows,node.js,phantomjs,protractor
Here's my conf file: exports.config = { seleniumServerJar: './selenium-server-standalone-2.43.1.jar', "capabilities": { "browserName": "phantomjs" }, specs: [ "test.js" ], jasmineNodeOpts: { isVerbose: false, showColors: true, includeStackTrace: true }, }; here's the called test.js .It is against ng-europe community site so everybody who wish will be able to run this.I choose it...

phantomjs command line never works

command-line,syntax,phantomjs,command-prompt
I'm trying to run a command line in the phantomjs prompt (to create a PDF screenshot of a website) So I launched phantomjs.exe and after the phantomjs> I typed : phantomjs rasterize.js http://www.google.com test1.pdf Whatever I type, I get a Expected an identifier but found 'rasterize' instead phantomjs://repl-input:1 in global...

Karma Test: PhantomJS: ReferenceError: Can't find variable: Audio

angularjs,html5,audio,phantomjs,karma-jasmine
I'm trying to use Karma and PhantomJS to test my app, and I'm getting the error: PhantomJS 1.9.8 (Windows 7) Controller: SongsCtrl should attach a list of awesomeThings to the scope FAILED ReferenceError: Can't find variable: Audio The offending line in my AngularJS Service is: var audio = new Audio();...

ngTransclude fails on PhantomJS

angularjs,phantomjs
So I'm developing a AngularJS website, and I have been charged with the task of making it friendly to facebook sharing and SEO. I've chosen PhantomJS as a possible solution, to evaluate the Javascript and spit out executed html code, which for now is just about filling the facebook meta...

PhantomJS cannot access member 'evaluate' of deleted QObject

javascript,phantomjs
function checkMessages(user, password, callback) { var page = require('webpage').create(); page.open('http://mywebpage.com', function (status) { if (status === 'fail') { console.log(user + ': ?'); } else { page.evaluate(function (user, password) { document.querySelector('input[name=username]').value = user; document.querySelector('input[name=password]').value = password; document.querySelector('button[name=yt0]').click(); }, user, password); waitFor(function() { return page.evaluate(function() { var el =...

Phantomjs 2.0.1 and woff

phantomjs,woff
Neither current windows nor linux binary (build on Ubuntu 14.04 with http://phantomjs.org/build.html) accept woff-fonts (via @font-face in CSS). Is there some kind of magic trick to switch woff support on? SVG and TTF font are accepted, but (i used ProcMon on widows) pantomjs do not make any attempts to search...

Can not download html with phantomjs [closed]

javascript,php,url,phantomjs
I have 3 different files in my project and the layout is phantomjs -->phantomjs.js -->phantomjs.exe index.php index.php: $phantom_script = dirname(__FILE__). '\phantomjs\phantomjs.js'; $response = exec ('\phantomjs\phantomjs.exe' . $phantom_script); echo $response; phantomjs\phantomjs.js var webPage = require('webpage'); var page = webPage.create(); page.open('http://www.google.com', function(status) { console.log(page.content); phantom.exit(); }); ...

Submitting an existing form with javascript returns undefined

javascript,forms,phantomjs
I'm trying to browse a website using PhantomJS and need to submit a form at some point (without using jQuery). The submit button code is : <button type="submit" class="submitButton"> <img src="button.png"> </button> When using the console, the element seems to be well identified : window.document.getElementsByClassName('submitButton') > <button type="submit" class="submitButton"> But...

Trouble Parsing Text using BeautifulSoup and Python

python,selenium,web-scraping,beautifulsoup,phantomjs
I am trying to retrieve the comment section on regulations.gov pages. An example is the paragraph "Restrictions on Proprietary Trading... with free market driven valuations." on http://www.regulations.gov/#!documentDetail;D=OCC-2011-0014-0032. I am using BeautifulSoup and Python and have the following code: from bs4 import BeautifulSoup from selenium import webdriver driver = webdriver.PhantomJS() driver.get(http://www.regulations.gov/#!documentDetail;D=OCC-2011-0014-0032)...

Why Phantomjs/Selenium remove duplicated attributes on single HTML element

html5,selenium-webdriver,html-parsing,phantomjs
Its seems that Phantomjs/selenium autmatically removes duplicate attributes on HTML elements. Does this forced from HTML standard itself (any pointer?)or some implementation defacto of webkit/gecko?

Timeout for webdriver.PhantomJS in python?

python,selenium,selenium-webdriver,phantomjs
I just use selenium-python. When I use webdriver.Firefox(), I can get the result. When I use webdriver.PhantomJS(), the result can't be returned (the script is hanging). Can anyone help me? browser = webdriver.PhantomJS(executable_path='./lib/phantomjs/phantomjs') url = "http://aminer.org/search/jie%20tang" browser.get(url) ...

background color phantomjs

css,phantomjs
The background color for a div or any kind of element is skipped by phantomjs. By default it's set in the CSS but I tried as well to set it with Javascript or as style parameters in the balise but nothing work out. I don't get any background color. How...

Blacklist and whitelist URLs in HtmlUnitDriver

javascript,selenium,phantomjs,htmlunit,htmlunit-driver
Blacklisting URLs in PhantomJS and GhostDriver is pretty straightforward. First initialize the driver with a handler: PhantomJSDriver driver = new PhantomJSDriver(); driver.executePhantomJS(loadFile("/phantomjs/handlers.js")) And configure the handler: this.onResourceRequested = function (requestData, networkRequest) { var allowedUrls = [ /https?:\/\/localhost.*/, /https?:\/\/.*\.example.com\/?.*/ ]; var disallowedUrls = [ /https?:\/\/nonono.com.*/ ]; function isUrlAllowed(url) { function matches(url)...

Click a button to download a file using CasperJS

javascript,unit-testing,phantomjs,casperjs
I want to write unit tests to download a file by clicking a form button using casperJS. I tried using document.getElementsByTagName to get to the button and clicked it in JavaScript's way. But I got an error message: TypeError: 'undefined' is not a function (evaluating 'inputs[1].click()') The segment of the...

Parallel-test Cucumber watir testing with phantomjs ECONREFUSED

cucumber,phantomjs,watir,watir-webdriver
I`m having issues with phantomjs with my parallel testing, firefox is running fine. I use parallel_tests, watir-webdriver, and Cucumber. No connection could be made because the target machine actively refused it. - connect(2) for "127.0.0.1" port 8910 (Errno::ECONNREFUSED) Tests are running via: parallel_cucumber features/parallel_tests -n 3 After some debugging I...

Phantomjs can't find the javascript file

javascript,windows,phantomjs
I am new to Phantomjs I just downloaded its version for Windows. I opened the bin folder and run the command in phantomjs.exe: phantomjs hello.js But it gives me the error : Expected an identifier bu found "hello" instead Then I run this command: hello.js I get this error :...

Rasterization with Javascript looks different on Apache server

javascript,apache,phantomjs,server,rasterizing
I am using phantomjs to rasterize an html page that I'm creating dynamically with javascript/php. It looks fine when testing on my localhost, but when testing on an apache server, it appears to blow the image up, causing it to be formatted wrong (extends to two pages instead of one,...

WebApp doesn't recognize that an input field was changed when set with jQuery in PhantomJS

javascript,jquery,javascript-events,phantomjs,html-input
I open telegram with PhantomJS and try to fill phone number input with evaluate page like below: page.evaluate(function(){ $("input[name='phone_number']").val("123456789"); }); When PhantomJS clicks on next button with jQuery the alert massage says "tel input is empty" but when the page is rendered we can see numbers in the input field....

Catch errors caused by evaluate() in CasperJS / PhantomJS?

javascript,phantomjs,casperjs
I'm wondering why the following code isn't picking up errors output in the console by javascript code executed using the evaluate() method. casper.on 'resource.error', -> @echo 'Resource error: ' + "Error code: "+resourceError.errorCode+" ErrorString: "+resourceError.errorString+" url: "+resourceError.url+" id: "+resourceError.id, "ERROR" Since evaluate() executes the code in the context of the...

Phantomjs not rendering Angular + Websockets page

angularjs,websocket,phantomjs,prerender
Running into a situation where some complex pages (complex in terms of nested views) are not rendering at all in Phantom (using http://prerender.io) I'm using: Phantom 1.9.8 Websocket 1.2.0 Angular 1.3.1 I think it's an issue with websockets because the pages I've tested that don't rely on sockets seem to...

Java And GhostDriver : Hide Console and Logs

java,selenium,phantomjs,ghostdriver
I try to hide the console and the log of GhostDriver in java... - Windows 7. - JDK is in 1.7.0_75 version. - PhantomJS 1.9.7 is include with it path. - GhostDriver 1.1.0 is include in an Eclipse Java SE Project. - Selenium 2.43.1 is include in an Eclipse Java...

Does phantomjs support Bayeux or WebSockets?

websocket,phantomjs,faye,bayeux
Just simple question, because I didn't find any references in docs..