phantomjs

How to connect to MongoDB using PhantomJS

烂漫一生 提交于 2019-12-21 19:19:12
问题 I'm Running OSX. Thought I could find documentation somewhere, but could not. 回答1: You can use a MongoDB REST client: Sleepy.Mangoose: It's the best IMO MongoDB REST: It looks promising, but is not complete yet and has some weird bugs (for example, it refused to send large requests (more than 80,000 characters) and it took me 3 hours to find what was wrong with it) MongoDB Java REST server You can connect directly to the rest server from you injected javascript (use jQuery's ajax method or

How to connect to MongoDB using PhantomJS

纵然是瞬间 提交于 2019-12-21 19:18:19
问题 I'm Running OSX. Thought I could find documentation somewhere, but could not. 回答1: You can use a MongoDB REST client: Sleepy.Mangoose: It's the best IMO MongoDB REST: It looks promising, but is not complete yet and has some weird bugs (for example, it refused to send large requests (more than 80,000 characters) and it took me 3 hours to find what was wrong with it) MongoDB Java REST server You can connect directly to the rest server from you injected javascript (use jQuery's ajax method or

Better way to take screenshot of a url in Python

試著忘記壹切 提交于 2019-12-21 17:45:32
问题 Problem Description Currently working on a project which requires me to take browse a url and take a screenshot of the webpage. After looking various resources i found 3 ways to do so.I will be mentioning all 3 methods iam currently using. Method - 1 : PhantomJS from selenium import webdriver import time import sys print 'Without Headless' _start = time.time() br = webdriver.PhantomJS() br.get('http://' + sys.argv[1]) br.save_screenshot('screenshot-phantom.png') br.quit _end = time.time()

Troubleshoot PhantomJS code to sign in to Instagram

两盒软妹~` 提交于 2019-12-21 17:06:12
问题 I've written this PhantomJS script to automate signing in to Instagram. It can successfully fill in the form fields and press the submit button, but it always gets redirected back to the logon screen with the following message: Your username or password was incorrect. I am 100% positive that the credentials are correct, and I tried it with multiple Instagram accounts. I'm running the script on a Mac from terminal: $ phantomjs --ssl-protocol=any --cookies-file=cookies.txt script.js username

Scrapy with selenium, webdriver failing to instantiate

旧城冷巷雨未停 提交于 2019-12-21 12:27:47
问题 I am trying to use selenium/phantomjs with scrapy and I'm riddled with errors. For example, take the following code snippet: def parse(self, resposne): while True: try: driver = webdriver.PhantomJS() # do some stuff driver.quit() break except (WebDriverException, TimeoutException): try: driver.quit() except UnboundLocalError: print "Driver failed to instantiate" time.sleep(3) continue A lot of the times the driver it seems it has failed to instantiate (so the driver is unbound, hence the

Testing a $interval with Jasmine in PhantomJS

杀马特。学长 韩版系。学妹 提交于 2019-12-21 07:47:41
问题 It appears that my interval is never triggered. I have a directive which contains a $interval and I want to test it. I've removed all the directive-related code and added this piece instead in its controller: window.called = 0; window.interval = $interval(function () { window.called++; console.log('interval ' + window.called); // 4 }, 10); console.log('initialized'); // 1 The test looks like this: describe('myDirective', function () { beforeEach(module('myModule')); beforeEach(function(

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

↘锁芯ラ 提交于 2019-12-21 05:43:12
问题 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, require('webpage') doesn't run ( Error: Module name "system" has not been loaded yet for context ) even though the

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

柔情痞子 提交于 2019-12-21 04:50:47
问题 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 code? 回答1: You can do it something like this: var page = require('webpage').create(), system = require('system'), resources = []; page.open('http://google.com', function (status) { console.log('Loaded with

PhantomJS not captured when ran via build server

六月ゝ 毕业季﹏ 提交于 2019-12-21 04:48:27
问题 I am using Karma and PhantomJS with Jasmine to test my AngularJS. When I run my gulp test locally it works fine, launches PhantomJS and runs all my tests, but when the tests get run on the build server it fails with the following errors: Note that I am using VSTS and using their built in cloud build system (hosted agent). Having said that its pretty much a task runner and I only use it to run gulp tasks (build, test etc) on checkin [32m13 07 2016 15:21:32.260:INFO [karma]: [39mKarma v1.1.1

Take screenshot from Karma while running tests in PhantomJS 2?

时光毁灭记忆、已成空白 提交于 2019-12-21 04:19:15
问题 I need a way to take a screenshot during a test which uses QUnit and Karma to run inside PhantomJS 2.0.1 I've found this command: window.top.callPhantom('render'); That doesn't throw any error but doesn't seem to work, or at least, I don't know where to look for the taken screenshot. Any clue? 回答1: Found a way! Solution I had to edit my custom PhantomJS custom launcher adding an option: PhantomJSCustom: { base: 'PhantomJS', options: { onCallback: function(data){ if (data.type === "render") {