phantomjs

While rendering webpage to pdf using phantomjs, how can I auto adjust my viewportSize to take full page width?

人盡茶涼 提交于 2019-12-01 05:52:44
I am able to specify the page size correctly using the params as below: var page = require('webpage').create(); page.paperSize = { format: 'Letter, orientation: 'Portrait'}; The challenge that I am facing is that, I cannot get my web page to take the full width of the paper. This is how I can set the viewport size: page.viewportSize = { width: mybestfitwidth, height: mybestfitheight }; The challenge here is that I cannot figure out what mybestfitwidth should be. I can tell the width of my pdf page in inches, but I can't figure out what number of pixels would that be, because that depends on

Can't require Underscore with CasperJS

老子叫甜甜 提交于 2019-12-01 05:32:08
问题 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'

How to move jquery-ui slider with CasperJS

三世轮回 提交于 2019-12-01 05:20:51
问题 Is there any way to move the jQuery UI – Slider with CasperJS ? I also found this github issue while searching for a possibility to just click on the left or right of the slider to move the handle . But this doesn't worked for me as well. Any idea? 回答1: To move the slider works as follows: casper.mouse.down(100,100); casper.mouse.move(200,200); casper.mouse.up(200,200); with casper.capture('test1.jpg'); called before and after the three mouse lines you should see the differene. 回答2: This is a

PhantomJS: page.open() does not respond when running in REPL

十年热恋 提交于 2019-12-01 05:04:25
问题 I'm trying to run some phantomJS by sending it in via Standard Input, but my webpage open does not respond. Here is the javascript I'm trying to execute: require('webpage').create().open('http://google.com', function() { console.log('done'); phantom.exit(); }); Pretty straight forward, right? Put that in a file.js, and use phantomjs.exe file.js and it works, but execute it via REPL phantomjs.exe phantomjs> require('webpage').create().open('http://google.com', function() { console.log('done');

How can I start PhantomJS + Selenium window in background?

ぃ、小莉子 提交于 2019-12-01 04:25:51
问题 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); 回答1: var serviceJs = PhantomJSDriverService.CreateDefaultService(phantomPath); serviceJs.HideCommandPromptWindow = true; Instance = new

exec() and phantomjs issue with absolute paths

匆匆过客 提交于 2019-12-01 04:15:08
I'm using phantomJS for the purposes of programmatically taking screenshots of a webpage. My webserver runs on Linux 64 bit. The Scenario My test.php file exec('./phantomjs --version', $o, $e); print_r($o); echo $e; I open test.php in a browser. The out put I get is: 1.9.1 // version number 0 // exit code This proves that I can run commands through exec() and phantomJS is working perfectly. The Issue Now when I replace the above code with: exec('./phantomjs http://mywebsite.com/test.js', $o, $e); print_r($o); echo $e; The output is: Array ( ) // empty output 139 // exit code which on

While rendering webpage to pdf using phantomjs, how can I auto adjust my viewportSize to take full page width?

元气小坏坏 提交于 2019-12-01 04:11:03
问题 I am able to specify the page size correctly using the params as below: var page = require('webpage').create(); page.paperSize = { format: 'Letter, orientation: 'Portrait'}; The challenge that I am facing is that, I cannot get my web page to take the full width of the paper. This is how I can set the viewport size: page.viewportSize = { width: mybestfitwidth, height: mybestfitheight }; The challenge here is that I cannot figure out what mybestfitwidth should be. I can tell the width of my pdf

Casperjs iterating over a list of links using casper.each

非 Y 不嫁゛ 提交于 2019-12-01 03:55:26
I am trying to use Casperjs to get a list of links from a page, then open each of those links, and add to an array object a particular type of data from those pages. The problem I am having is with the loop that executes over each of the list items. First I get a listOfLinks from the original page. This part works and using length I can check that this list is populated. However, using the loop statement this.each as below, none of the console statements ever show up and casperjs appears to skip over this block. Replacing this.each with a standard for loop, the execution only gets part way

casperjs doesn't work as expected on windows machine

妖精的绣舞 提交于 2019-12-01 02:49:04
I have a casperjs script which gives the desired result when I run on a linux server, but when I run the same from my laptop, it doesn't work. How should I debug? Logs of the working one: [info] [phantom] Starting... [info] [phantom] Running suite: 3 steps [debug] [phantom] opening url: http://caspertest.grsrv.com/, HTTP GET [debug] [phantom] Navigation requested: url=http://caspertest.grsrv.com/, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app, type=Other, willNavigate=true, isMainFrame=true [debug] [phantom]

How to Login by filling the form in CasperJs

ⅰ亾dé卋堺 提交于 2019-12-01 02:31:08
Following is the hlml of the login form that I have <div class="login_area_user"> <form method="post" action="https://www.tradus.com/login?dest_url=https://www.tradus.com/cart/select-address" id="user-login"> <input type="hidden" value="1" name="form_submit"> <h3 style="display:inline-block;">Already a Member</h3> <p id="login-main-center-right-descp">You can use tradus login id and password</p> <div class="login-row"> <label class="colorBlack">Email / Login*</label> <input class="login-field" type="text" name="name" id="edit-namepopup"> </div> <!-- [/login-row] --> <div class="login-row">