phantomjs

How to set screen/window size when using GhostDriver

霸气de小男生 提交于 2019-12-01 08:48:16
I am using the GhostDriver as the WebDriver implementation in a Java-based project. I want to take snapshots of the pages. The default page size is kind of awkward, so I want to control the page size of the snapshots. However, I can't find any examples from Google. So, can someone tell me how? Thank you very much. Have you tried setSize() method from WebDriver.Window ? Here is the documentation. // untested Java code, only provides the logic // please debug and refer to the documentation import org.openqa.selenium.Dimension; WebDriver driver = new PhantomJSDriver(); driver.manage().window()

Phantomjs connection to Facebook fails SSL handshake [duplicate]

白昼怎懂夜的黑 提交于 2019-12-01 08:27:57
This question already has an answer here: PhantomJS failing to open HTTPS site 12 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 a solution for this? I am running phantomjs version 1.9.7. I have posted my code and my error output below. var system = require('system'); var page = require('webpage').create(); page.open('https://www.facebook.com', function(status){ console.log("status: " + status); if(status === "success"){ console.log("no error")

How to configure Poltergeist or PhantomJS to not follow redirects?

99封情书 提交于 2019-12-01 08:11:51
I have some tests that require the JS driver to not follow redirects. Is it possible to configure Poltergeist to do this? I noticed that it is possible to pass commands to PhantomJS using the Command Line Interface , so perhaps that is another way of doing this? I'm not familiar with Poltergeist, so I'm only going to answer about PhantomJS. All you need for this are the two event handlers page.onResourceRequested and page.onResourceReceived . An HTTP redirect produces both a HTTP request and HTTP response on so the handlers are called when the redirect response is received. You can then add

How can I start PhantomJS + Selenium window in background?

十年热恋 提交于 2019-12-01 07:37:41
I'm using selenium + phantomjs in my application, but I want to start my application, selenium and phantomjs window in background. How can I do it? I tried: PhantomJSOptions options = new PhantomJSOptions(); options.AddAdditionalCapability("start-maximized", false); IWebDriver driver = new PhantomJSDriver(Environment.CurrentDirectory + @"\drivers", options); var serviceJs = PhantomJSDriverService.CreateDefaultService(phantomPath); serviceJs.HideCommandPromptWindow = true; Instance = new PhantomJSDriver(serviceJs); 来源: https://stackoverflow.com/questions/26133336/how-can-i-start-phantomjs

Can't require Underscore with CasperJS

强颜欢笑 提交于 2019-12-01 07:31:17
I'm using CasperJS to run automated frontend tests but have run in to an issue with using other npm modules in my tests. I'm aware of patchRequire however I believe that is only to be called outside of the test environment as the test runner patches require automatically. I did include it but the results were the same. It says it can't find the module. I have confirmed the underscore module is installed in node_modules in the projects root folder. Code 'use strict' _ = require 'underscore' testConfig = testPageUrl: '' testSearchTerm: 'the' config = _.extend testConfig, require 'common/config'

Permission denied when run casperjs in iron.io

浪尽此生 提交于 2019-12-01 07:26:49
问题 I'm testing casperjs in iron.io as this example https://github.com/iron-io/iron_worker_examples/blob/master/binary/casperjs/googlelinks.js but when iron_worker complete this task, it gives an error message ./run.sh: 2: ./run.sh: casperjs/bin/casperjs: Permission denied Any idea on how to fix this? Thanks 回答1: in run.sh: .. chmod +x casperjs/bin/casperjs .. 来源: https://stackoverflow.com/questions/18449084/permission-denied-when-run-casperjs-in-iron-io

Can't pass array items to function in PhantomJS

試著忘記壹切 提交于 2019-12-01 07:26:49
问题 I am trying to pull the source code to several webpages at once. The links are fed into the array via a source text file. I am able to iterate through the array and print out the links and confirm they are there, but when trying to pass them through a function, they become undefined after the first iteration. My ultimate goal is to have it save the source of each page to its own document. It does the first page correctly, but subsequent attempts are undefined. I've searched for hours but

How to set screen/window size when using GhostDriver

为君一笑 提交于 2019-12-01 07:17:07
问题 I am using the GhostDriver as the WebDriver implementation in a Java-based project. I want to take snapshots of the pages. The default page size is kind of awkward, so I want to control the page size of the snapshots. However, I can't find any examples from Google. So, can someone tell me how? Thank you very much. 回答1: Have you tried setSize() method from WebDriver.Window ? Here is the documentation. // untested Java code, only provides the logic // please debug and refer to the documentation

Dump HTML of page including iframes

跟風遠走 提交于 2019-12-01 07:01:19
问题 I'd like to dump the HTML contents of a web page, including the HTML of iframes included inside the <iframe> elements. The Chrome Developer Tools "Elements" tab is capable of showing iframe embedded in this way. When I say "dump the HTML contents" I'm interested in browser automation tools like Selenium or PhantomJS. Do any of these tools have this capacity built in? For example, the HTML dump I'd like of this page should include the HTML source of this embedded page. 回答1: You can use

Unsafe javascript attempt to access frame when installing casperjs through npm windows

妖精的绣舞 提交于 2019-12-01 06:10:44
I have installed casperjs and phantomjs on my windows machina via npm. However I get this issue. C:\>casperjs sample.js C:\>Unable to open file: sample.js Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///C:/Users/vini/AppData/Roaming/npm/node_modules/casperjs/bin/bootstrap.js. Domains, protocols and ports must match. Artjom B. This is a known issue with CasperJS and the 1.9.8 version of PhantomJS. It doesn't do anything and the errors are only printed during exit. They don't interfere with your script. There is a workaround and it was merged into