phantomjs

Selenium/PhantomJS raises error

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to run PhantomJS driver in Python but I'm getting error. I've read that I should pass the whole path as an argument but it didn't help. Here is the code: from selenium import webdriver # driver = webdriver.Chrome('D:\Python_projects\chromedriver_win32/chromedriver.exe') # this works driver = webdriver.PhantomJS(executable_path='D:\Python\phantomjs-2.0.0-windows\bin\phantomjs.exe') ERROR: Traceback (most recent call last): File "path to script", line 8, in <module> driver = webdriver.PhantomJS(executable_path='D:\Python\phantomjs-2

Python Selenium with Phantomjs - Click Failed: ReferenceError: Cant&#039;t find variable

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Im writing a python script using selenium webdriver to get some data from a website, and Im trying to click the next button in this webpage. Where the button is defined: <a id="ctl00_FullRegion_npsGridView_lnkNext" class="nextCol" href="javascript:__doPostBack('ctl00$FullRegion$npsGridView$lnkNext','')">Next</a> Wih the following code in python URL='http://www.nordpoolspot.com/Market-data1/Elspot/Area-Prices/ALL1/Hourly/' nextId="ctl00_FullRegion_npsGridView_lnkNext" browser=webdriver.PhantomJS('./phantomjs') browser.get(URL) nextBtn=browser

phantomjs page.evaluate not logging onto console

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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); }); 回答1: The call page.evaluate() runs your

Trouble connecting to phantomJs webdriver using python and selenium

匿名 (未验证) 提交于 2019-12-03 01:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: 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

Jasmine/PhantomJs spec runner

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I cannot get my test to run using phantomJs. gulp task var jasminePhantomJs = require ( 'gulp-jasmine2-phantomjs' ); gulp . task ( 'test' , function () { return gulp . src ( './SpecRunner.html' ) . pipe ( jasminePhantomJs ()); }); SpecRunner.html <script src = "lib/jquery.min.js" ></script> <script src = "lib/lodash.min.js" ></script> <script type = "text/javascript" src = "lib/jasmine-2.0.0/jasmine.js" ></script> <script type = "text/javascript" src = "lib/jasmine-2.0.0/jasmine-html.js" ></script> <script type = "text/javascript"

phantomjs: command not found

匿名 (未验证) 提交于 2019-12-03 01:32:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I followed these instructions (except for copying the executable to my PATH because I cannot seem to find it and it does not seem necessary). Then I made a file called image_render.js in my public javascripts directory with console . log ( 'Hello, world!' ); phantom . exit (); inside it, saved it, and ran phantomjs render_image.js in my terminal. However, my terminal does not recognize the command: - bash : phantomjs : command not found What have I done wrong? 回答1: The PATH really is the important part. You can skip it, however, if

SyntaxError: Unexpected token &#039;const&#039; for testing.es5.js

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've switched to Angular4.0.0-rc.1 and it looks like ES5 testing bundles contain ES2015 code. I'm getting this error: PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR SyntaxError: Unexpected token 'const' at webpack:///~/@angular/core/@angular/core/testing.es5.js:10:0 Also found related issue on Angular repo. 回答1: I just created a basic Angular project and had the same (or similar) issue with PhantomJS integration. PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR SyntaxError: Unexpected token 'const' at webpack:///src/app/app.component.ts:1:0 Our team got it to

Phantomjs doesn't render footers with a custom styles

久未见 提交于 2019-12-03 01:26:38
I have the following example: var page = require('webpage').create(), system = require('system'); if (system.args.length < 3) { console.log('Usage: printheaderfooter.js URL filename'); phantom.exit(1); } else { var address = system.args[1]; var output = system.args[2]; page.viewportSize = { width: 600, height: 600 }; page.paperSize = { format: 'A4', margin: "1cm" footer: { height: "1cm", contents: phantom.callback(function(pageNum, numPages) { if (pageNum == numPages) { return ""; } return "<h1 class='footer_style'>Footer" + pageNum + " / " + numPages + "</h1>"; }) } }; page.open(address,

Karma unit testing: Module name “react” has not been loaded yet for context: _. Use require([])

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to set up the unit testing framework for react. While doing so, the following error has occurred. I have searched all over the internet with no solution that is working. below are the errors shown and code/packages that I am using. debug error 04 03 2016 04 : 48 : 46.340 : DEBUG [ phantomjs . launcher ]: Error : Module name "react" has not been loaded yet for context : _ . Use require ([]) http : //requirejs.org/docs/errors.html#notloaded 04 03 2016 04 : 48 : 46.341 : DEBUG [ phantomjs . launcher ]: http : //localhost

PhantomJS- open page with LocalStorage by default

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using PhantomJS to get the generated source of a web page after JavaScript DOM manipulations have taken place. This web page has JUST a and nothing else. Important : This web page uses browser's localStorage to generate the page. I want to change LocalStorage in PhantomJS before opening the page. App.js : var page = require('webpage').create(); page.open("https://sample.com") setTimeout(function(){ // Where you want to save it page.render("screenshoot.png") // You can access its content using jQuery var fbcomments = page.evaluate