phantomjs

How to perfectly isolate and clear environments between each test?

核能气质少年 提交于 2019-12-06 02:29:57
问题 I'm trying to connect to SoundCloud using CasperJS. What is interesting is once you signed in and rerun the login feature later, the previous login is still active. Before going any further, here is the code: casper.thenOpen('https://soundcloud.com/', function() { casper.click('.header__login'); popup = /soundcloud\.com\/connect/; casper.waitForPopup(popup, function() { casper.withPopup(popup, function() { selectors = { '#username': username, '#password': password }; casper.fillSelectors(

Phantom JS Error with youtube video

馋奶兔 提交于 2019-12-06 02:22:22
问题 Phantom JS Version: 1.9.1 Poltergeist Version: 1.3.0 Starting today youtube embedded videos now give a poltergeist error when running javascript tests. My youtube code is just the default embed youtube code. Here's a example: <iframe width="560" height="315" src="//www.youtube.com/embed/AW9Z3cGOlGM?rel=0" frameborder="0" allowfullscreen></iframe> And the errors I get just from visiting that page while enabling javascript is: Failure/Error: page.find(".container.registrations.false.government"

PhantomJSDriver Accept Alert

☆樱花仙子☆ 提交于 2019-12-06 02:21:53
问题 How can I accept an alert with PhantomJSDriver in Java? I am trying to do this with YouTube. I can't get it to work. I've tried using this code to accept on any driver but it doesn't work with PhantomJS. static void confirmDialog(WebDriver driver) { if (driver instanceof PhantomJSDriver) { PhantomJSDriver phantom = (PhantomJSDriver) driver; phantom.executeScript("window.confirm = function(){return true;}"); phantom.executeScript("return window.confirm"); } else driver.switchTo().alert()

How do I load Google Charts in node.js?

你离开我真会死。 提交于 2019-12-06 02:15:11
When I attempt to load a Google Chart in node.js, nothing happens. I tried loading the first example from the line chart docs in both zombie.js and jsdom, but the chart never loads in either case. The end goal is to retrieve the SVG data of the generated chart for export into an image or PDF. So if an alternate method (server side using node.js or PHP) to achieve this is possible, I'm open to suggestions. NOTE : I have successfully generated a images of a few charts using gChartPhp, but the requirements of this project state that the embedded version be the interactive version provided by the

Scrapping of the Twitter follower page using selenium and phantomjs

拈花ヽ惹草 提交于 2019-12-06 01:43:56
I am trying to get the follower list of a given Twitter account. To do so, I manage to connect to my account using Selenium and PhantomJS (v2.1.1). Then, since Twitter is using infinite scrolling, I would like to implement the following algorithm: 1/ Count the number of html elements with class attribute equals ProfileCard-screennameLink 2/ Repeat: -Scroll down -Count the number of html elements with class attribute equals ProfileCard-screennameLink Until the number of elements does not change My problem is that the scrolling function does not work. Indeed, when I am running elemsCount =

How to disable JavaScript in PhantomJS through Selenium WebDriver

不想你离开。 提交于 2019-12-06 01:34:02
I want to disable JavaScript while scraping using scrapy and selenium. Moto of doing that is to increase scraping speed. I found the preference for Firefox driver but not PhantomJS. firefox_profile = webdriver.FirefoxProfile() firefox_profile.set_preference("javascript.enabled", False) driver = webdriver.Firefox(firefox_profile=firefox_profile) driver.get('http://www.quora.com/') How can this be done for PhantomJS webdriver? The WebDriver protocol in PhantomJS is a pure JavaScript implementation that is known as Ghostdriver. It makes heavy use of page.evaluate() to access the DOM and there is

How can I force PhantomJS to wait until MathJax is finished?

ぐ巨炮叔叔 提交于 2019-12-06 01:22:11
I'm trying to pre-render a MathJax html file using PhantomJS. For example, suppose in math.html I have: <!DOCTYPE html> <html> <head> <script type="text/javascript" src="MathJax/MathJax.js"></script> <script src="ConfigMathJax.js"></script> </head> <body> <span class="math">\(e = m c^2\)</span> </body> </html> My (broken) render script currently looks like: var page = require('webpage').create(); var system = require('system'); var fs = require('fs'); page.open(system.args[1], function () { page.evaluate(function(){ var flag = false; MathJax.Hub.Queue(["Typeset",MathJax.Hub]); MathJax.Hub

PhantomJS .click() not working

99封情书 提交于 2019-12-06 00:43:34
问题 This code does not work: var page = require('webpage').create(); page.open('http://www.ebay.com/', function() { console.log('Page loaded'); page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js', function() { console.log('jQuery included'); page.render('C:/beforeclick.jpeg'); console.log('Render 1'); page.evaluate(function() { $('.btn-prim').click(); }); page.render('C:/afterclick.jpeg'); console.log('Render 2'); }); }); In fact $('.btn-prim').click() does not work,

testing DOM elements with phantomjs/casperjs

為{幸葍}努か 提交于 2019-12-06 00:04:22
I've got an AJAX-based javascript application which I would like to cover with interface tests. For example, I would like to write a test that loads my website (from a given URL) and checks if there are some DOM elements (given ids and given classes) that exist. The problem is that when I enter the URL in a browser, my application has a Loading... label displayed and an AJAX request is sent beneath. When AJAX response arrives, some processing is done and the right webpage content is displayed ( Loading... label is hidden). So far I've got this code: casper.test.begin('Main page test', 2,

Does PhantomJS support ES6 for serving angularjs app to crawlers and bots?

廉价感情. 提交于 2019-12-05 23:31:23
问题 I am trying to use ajax-seo for an Angularjs app to serve html compiled content from a PhantomJS webserver`. But it's not rendering the complete page. It's just giving the following response <html><head></head><body></body></html> I have followed the instructions well but no luck so far. So I'd like to know whether PhantomJS supports ES6 or not, because my app is in ES6. 回答1: PhantomJS 2.1.1 only supports about 10% of ECMAScript 6, which might not be enough to properly render your page. Here