phantomjs

PhantomJS: injecting a script before any other scripts run

隐身守侯 提交于 2019-11-30 13:40:00
问题 Using PhantomJS, I'd like to inject some JS as if there was an extra <script> tag before any other <script> tags. This is because the scripts on the page use some functions that PhantomJS does not have, namely Function.prototype.bind and window.webkitRequestAnimationFrame . I have a JS file with custom implementations of the two and I'd like PhantomJS to use them when running the scripts on the page. The difficulty is that if I do page.injectJs before page.open, the script is injected into an

phantomjs page.evaluate not logging onto console

风流意气都作罢 提交于 2019-11-30 13:08:51
问题 I am a PhantomJs newbie. Just checked a similar post on this site. My question is why 'foo' is not logged to console or printed? var page = require('webpage').create() var foo = 42; function evaluate(page, func) { var args = [].slice.call(arguments, 2); var fn = "function() { return (" + func.toString() + ").apply(this, " + JSON.stringify(args) + ");}"; return page.evaluate(fn); } page.open('http://google.com', function() { var foo = 42; evaluate(page, function(foo) { console.log(foo); },foo)

How can I wait for the page to be ready in PhantomJS?

二次信任 提交于 2019-11-30 12:57:07
问题 I'm using PhantomJS to log into a site an do something. The site used OAuth for logging in. Clicking on the "Login" button on the, takes you to the OAuth service. There you enter your credentials and clicking "Submit", you get redirected back to the original site. My script works fine but relies on timeouts which doesn't seem too robust. How can I rewrite this code so that instead of using setTimeout , I can wait until the page is ready. I often see errors that the page isnt' ready and

Selenium with GhostDriver in Python on Windows

对着背影说爱祢 提交于 2019-11-30 12:06:58
This is embarrassing to ask because it seems like something with so slim chance of error. I wouldn't think this would be difficult, but I've been plugging away at this for almost 3 hours now and it's giving me a headache. I've read several dozen stackoverflow threads and Google threads. I've installed PhantomJS, added it to my System Variables PATH, and it works properly in the command line. I also installed Selenium earlier with easy_install. The error I get is: __init__ C:\Python27\lib\site-packages\selenium-2.39.0-py2.7.egg\selenium\webdriver\phantomjs\webdriver.py 50 start C:\Python27\lib

Implementing waitFor functionality with phantomjs-node

不想你离开。 提交于 2019-11-30 11:46:02
I have tried and tested - with success - the phantomjs example waitFor . However, I am having difficulty implementing it via the phantomjs-node module primarily because page.evaluate gets evaluated in a callback. PhantomJS Implementation page.open("http://twitter.com/#!/sencha", function () { waitFor(function() { // This here is easy to do as the evaluate method returns immediately return page.evaluate(function() { return $("#signin-dropdown").is(":visible"); }); }, function() { console.log("The sign-in dialog should be visible now."); phantom.exit(); }); } }); However, with phantomjs-node the

Protractor running tests on PhantomJS

狂风中的少年 提交于 2019-11-30 11:34:48
问题 I can't seem to get PhantomJS through a test successfully. I tried to integrate it into my project, but after that failed I tried to just run the basic Angular Docs samples and I'm getting the same issue. My steps so far: npm install -g phantomjs phantomjs --webdriver=9515 // ... GhostDriver - Main - running on port 9515 protractor protractorConf.js This is the same file from the example with only browserName, and seleniumAddress port changed: // An example configuration file. exports.config

Output client-side console with casper/phantomjs

我与影子孤独终老i 提交于 2019-11-30 11:04:49
Going through the casperjs documentation I couldn't find where I could see the console.log from client-side javascript. Is this possible? 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 page DOM console.log('from the browser, I can tell you there are ' + log.length + ' entries in the log'); },

Install PhantomJS on MacOs 10.11 El Captian

你说的曾经没有我的故事 提交于 2019-11-30 10:52:35
I can't install phantomJs in my macbook after upgrading to 10.11 (El Capitan). Whenever I try to install it using homebrew it gives me this error: $ brew install phantomjs phantomjs: OS X Yosemite or older is required. Error: An unsatisfied requirement failed this build. Something is broken since Xcode 7 , if you have npm you can install it: npm install -g phantomjs-prebuilt Now that the issue have been handled, you can download it . Note that : npm install -g phantomjs Will install v1.9.8 The latest preview version v2.0.1 works correctly on 10.11 El Captian is available as a binary download .

phantomJS webpage timeout

感情迁移 提交于 2019-11-30 10:24:23
问题 I have set up a script to create webshots of our app. It runs perfectly and all is fine Until I encounter an image with a broken url : "<img src='http://testserver.our.intranet/fetch/image/373e8fd2339696e2feeb680b765d626e' />" I have managed to break the script after 6 seconds using the below, Before it was just looping forever. But, is it possible to ignore the network request ( AKA take the image out of DOM ) and then proceed to create the thumb without the image, (or with an injected image

Trouble connecting to phantomJs webdriver using python and selenium

♀尐吖头ヾ 提交于 2019-11-30 10:23:55
I am trying to run a python script on a linux server which uses selenium and a phantomjs webdriver; however, I keep getting the following error message: selenium.common.exceptions.WebDriverException: Message: Service /home/ubuntu/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs unexpectedly exited. Status code was: 127 Here is a simple test script that fails and generates this error: import selenium from selenium import webdriver driver = webdriver.PhantomJS(executable_path='/home/ubuntu/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs') calling file on the path, returns: