phantomjs

Cucumber-js: World constructor example with phantomjs

浪子不回头ぞ 提交于 2019-12-09 23:57:51
问题 In the cucumber-js page is showed an example with Zombie: // features/support/world.js var zombie = require('zombie'); var WorldConstructor = function WorldConstructor(callback) { var browser = new zombie(); var world = { browser: browser, // this.browser will be available in step definitions visit: function(url, callback) { // this.visit will be available in step definitions this.browser.visit(url, callback); } }; callback(world); // tell Cucumber we're finished and to use our world object

How to use NodeJS / PhantomJS / CasperJS on Windows 7

夙愿已清 提交于 2019-12-09 23:42:44
问题 I need to scrape a website form (on-the-fly) which has AJAX and SESSIONS. I did a lot of research and I came across several possible solutions one being Python::Mechanize. I don't know python and cURL alone for PHP (from my understanding) cannot handle AJAX or submit forms. I found what i believe is the possible stack which can lead me to grace :). Problem is that I do not know how to use these packages at all. I downloaded and installed NODEjs and I can call it from cmd. (great) I downloaded

CasperJs clicking links in a nested loop

谁说我不能喝 提交于 2019-12-09 23:23:41
问题 I'm trying to use PhantomJS/CasperJS to scrape a webpage. I've spent the last few days reading the docs, and searching online, but I'm stuck. The page I'm scraping shows three levels of links - years, months, and days. When you select a Year, Month, and day, a count appears in the #count div. Also, the months are actually inputs that change an image in the #imageLoad div (which I don't need). <div id="years"> <span class="year">2010</span> <span class="year">2011</span> <span class="year"

Phantomjs equivalent of browser's “Save Page As… Webpage, complete”

拟墨画扇 提交于 2019-12-09 23:19:57
问题 For my application I need to programmatically save a copy of a webpage HTML along with the images and resources needed to render it. Browsers have this functionality in their Save page as... Webpage, complete options. It is of course easy to save the rendered HTML of a page using phantomjs or casperjs. However, I have not seen any examples of combining this with downloading the associated images, and doing the needed DOM changes to use the downloaded images. Given that this functionality

How to get the response after a POST request in CasperJS

笑着哭i 提交于 2019-12-09 20:55:34
问题 I have this very simple code to read the response from a server endpoint after a post request. Actually I'm saving a data to a database and wait for a response before going to next step casper.open('http://example.com/ajax.php, { method: 'POST', data: { 'title': '<title>', 'unique_id': '<unique_id>' } }); on ajax.php file I'm trying to echo the POST request in a simple way. this will let me know easily if I'm getting the right response from the server. echo json_encode($_POST); I tried these

Cannot navigate with casperjs evaluate and __doPostBack function

流过昼夜 提交于 2019-12-09 19:14:24
问题 When I try to navigate the pagination on sites with links where href is a __doPostBack function call, I never achieve the page change. I am not sure what I am missing, so after a few hours of messing around I decided to see if someone here can give me a clue. This is my code (uber-simplified to show the use case). var casper = require('casper').create({ verbose: true, logLevel: "debug" }); casper.start('http://www.gallito.com.uy/inmuebles/venta'); // here i simulate the click on a link in the

@javascript cucumber tests pass using selenium driver but fail when using poltergiest

十年热恋 提交于 2019-12-09 16:50:17
问题 I'm trying to test an jquery UI autocomplete, I've got the tests passing using the selenium driver. I want to switch to poltergiest for some headless testing, but now my tests are now failing. It doesn't seem to select the autocomplete option for some reason that I have yet been able to figure out Step When /^select contract$/ do VCR.use_cassette("contract") do selector = '.ui-menu-item a:contains("John Smith (123456)")' within("div#review") do fill_in("contract", with: "john") end sleep 2

Injecting & using Firebug-Lite with PhantomJS

巧了我就是萌 提交于 2019-12-09 14:16:37
问题 I'm trying to inject Firebug & jQuery into a webpage using PhantomJS, but I'm unable to access them. I've tried both PhantomJS methods for adding other JS to a page: page.injectJs() and page.includeJs. I'm not able to get anything returned from includeJs (which I wasn't expecting to get, from reading the documentation). After I injectJs() and try to use firebug-lite and jQuery functions or objects (like $ and inspect() ) I get errors saying they are undefined or the variable can't be found.

Centos7下利用Selenium和PhantomJS搭建自动化测试环境

早过忘川 提交于 2019-12-09 13:50:36
为了在linux下搭建selenium自动化测试,折腾了4天。期间参考了无数博文,但是都是不成功。 现整理一下本人搭建的过程,让有需要的人参考。 先安装apache和selenium。 1.安装 apache : yum install httpd 2. 配置apache 进入vi /etc/httpd/conf/httpd.conf中,修改ServerName localhost:80 3.保存,:wq 4.重启apache服务,service httpd restart Selenium的安装过程照着下面这位博友的即可。 1.下载get-pip.py wget https://bootstrap.pypa.io/get-pip.py 2.查看一下python版本,centos自带的是python2.6.6版本,我已经把它升级到了2.7.10,这是目前最新的版本。( 本人centOS7,python自带版本Python 2.7.5 ) python -V 3.安装pip。找到刚才下载的get-pip.py python get-pip.py 4.如果你没有安装setuptools,会一并安装,看下图 5.pip安装成功后就可以使用它安装selenium了 pip install -U selenium 以上 Selenium的安装过程 摘自 https://my.oschina

Windows authentication using phantomjs

不想你离开。 提交于 2019-12-09 11:50:36
问题 I'm looking into phantomjs as a possible solution for UI automation in my latest project, but I can't seem to get windows authentication to work properly. I've tried setting the page.settings.userName and page.settings.password , but the snippet below always gets a 401 and the underlying stack makes no effort to resolve it. My search-fu has failed me, so I come to the community to ask for help. var page = require('webpage').create(); page.onResourceReceived = function(response) { phantom.exit