GVKun编程网logo

javascript – PhantomJS崩溃 – 退出代码126(js退出程序)

3

对于javascript–PhantomJS崩溃–退出代码126感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍js退出程序,并为您提供关于java–bash脚本出错“退出代码126”、java

对于javascript – PhantomJS崩溃 – 退出代码126感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍js退出程序,并为您提供关于java – bash脚本出错“退出代码126”、javascript - 如何使用phantomjs获取截图并保存、javascript – Jasmine测试在Chrome和Firefox中传递,但在PhantomJS中失败、javascript – mocha init超时与mocha-phantomjs的有用信息。

本文目录一览:

javascript – PhantomJS崩溃 – 退出代码126(js退出程序)

javascript – PhantomJS崩溃 – 退出代码126(js退出程序)

在CentOS(64位)系统上尝试运行phantomJS时,我遇到了一个奇怪的问题.

这是它报告的错误:

[4mRunning "qunit:all" (qunit) task[24m Testing http://localhost:8000/tests.html 

Running PhantomJS...[31mERROR[39m
[31m>> [39m/home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: /home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: cannot execute binary file 0 [ '/home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: /home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: cannot execute binary file' ]

[33mWarning: PhantomJS exited unexpectedly with exit code 126. Use --force to continue.[39m

[31mAborted due to warnings.[39m

我似乎无法找到关于此类崩溃的任何好文档.这通常和/或值得一个bug报告吗?

更新:

这些是我文件的权限:

-rwxr-x--x. 1 root root 11308856 Sep 26 12:39 phantomjs

解决方法

听起来它不是为你试图运行它的平台而构建的.确保删除node_modules目录,并在将存储库克隆到新平台时执行全新的npm安装.目前,将node_nodules目录包含在源代码控制中是不好的做法.只需保持您的package.json文件保持良好,并为每个repo克隆执行npm install或npm update.另外,如果您正在使用git,请将node_modules /添加到您的.gitignore文件中,这样您就不必担心在添加更改和提交时意外包含它.

java – bash脚本出错“退出代码126”

java – bash脚本出错“退出代码126”

我想将CPD(复制粘贴检测)集成到我的iOS项目中.我读到了它 here和 here.

要在代码中自动确定copyPaste,我正在使用bash脚本:

echo "Checking files in ${SOURCE_ROOT}"
JARS_DIR=${PROJECT_DIR}/CPD
FULL_PATH_TO_CPD_XML_OUTPUT=${PROJECT_DIR}/cpd-output.xml

# Running CPD
java -classpath "${JARS_DIR}/ObjCLanguage-0.0.5-SNAPSHOT.jar:${JARS_DIR}/pmd.jar" net.sourceforge.pmd.cpd.CPD --minimum-tokens 100 --files "${SOURCE_ROOT}" -v --language ObjectiveC --encoding UTF-8 --format net.sourceforge.pmd.cpd.XMLRenderer > "${FULL_PATH_TO_CPD_XML_OUTPUT}"

# Running self :)
${BUILT_PRODUCTS_DIR} -cpd-xml "${FULL_PATH_TO_CPD_XML_OUTPUT}"

该代码创建了cpd-output.xml文件.但是在编译时带错了“Command / bin / sh失败,退出代码为126”.这是日志副本http://pastebin.com/359k1Wni
我从example project中获取了代码
错误发生然后我评论这个字符串:

${BUILT_PRODUCTS_DIR} -cpd-xml "${FULL_PATH_TO_CPD_XML_OUTPUT}"

我试图找到有关此错误的信息,但发现只有少数这些问题没有答案.我对bash脚本没什么了解.任何建议我都会很满意.
感谢您的关注.

附:写下脚本的作者:

In order to integrate XCode and the CPD,we will add to the Build
Phases target with the project,Run Script phase,conventionally
consisting of several parts: Actually calling cpd Parsing
cpd-output.xml Output in the “right format”

解决方法

126 for “command not executable”

# Running self :)
${BUILT_PRODUCTS_DIR} -cpd-xml "${FULL_PATH_TO_CPD_XML_OUTPUT}"

看起来$BUILT_PRODUCTS_DIR}不可执行你能用这个var的值更新吗?

javascript - 如何使用phantomjs获取截图并保存

javascript - 如何使用phantomjs获取截图并保存

这是我的js代码:

var page = require(''webpage'').create();
var address = ''http://baidu.com'';//填写需要打印的文件位置
var output = ''./img/''+''xigua''+''.png'';//存储文件路径和名称
page.viewportSize = { width: 100, height: 100 };//设置长宽
page.open(address, function (status) {
    if (status !== ''success'') {
        console.log(''Unable to load the address!'');
        phantom.exit();
    } else {
        window.setTimeout(function () {
            page.render(output);
            phantom.exit();
        }, 500);
    }
});
登录后复制
登录后复制

这是php代码:

立即学习“Java免费学习笔记(深入)”;

点击下载“修复打印机驱动工具”;

<?php $command = ''phantomjs ''.''phantomjs\123.js''; //上面提到的js文件的路径
exec($command,$out);
登录后复制
登录后复制

使用以上的代码是可以截图并且保存的,但是无法动态生成图片名.
比如现在需求是保存的图片名称是订单号,就不知道如何传值,然后尝试使用.php来保存上面的js代码,以为这样可以使用动态的名称了,但是也遇到比较多的问题,所以请教各位大神如何传值,才能让phantomjs保存图片名的时候实现动态定义?谢谢.

回复内容:

这是我的js代码:

var page = require(''webpage'').create();
var address = ''http://baidu.com'';//填写需要打印的文件位置
var output = ''./img/''+''xigua''+''.png'';//存储文件路径和名称
page.viewportSize = { width: 100, height: 100 };//设置长宽
page.open(address, function (status) {
    if (status !== ''success'') {
        console.log(''Unable to load the address!'');
        phantom.exit();
    } else {
        window.setTimeout(function () {
            page.render(output);
            phantom.exit();
        }, 500);
    }
});
登录后复制
登录后复制

这是php代码:

立即学习“Java免费学习笔记(深入)”;

点击下载“修复打印机驱动工具”;

<?php $command = ''phantomjs ''.''phantomjs\123.js''; //上面提到的js文件的路径
exec($command,$out);
登录后复制
登录后复制

使用以上的代码是可以截图并且保存的,但是无法动态生成图片名.
比如现在需求是保存的图片名称是订单号,就不知道如何传值,然后尝试使用.php来保存上面的js代码,以为这样可以使用动态的名称了,但是也遇到比较多的问题,所以请教各位大神如何传值,才能让phantomjs保存图片名的时候实现动态定义?谢谢.

给phantomjs传递参数,比如

phantomjs phantomjs/123.js tupianming
登录后复制

在phantomjs里获取参数

var args = require(''system'').args;
//args[1]就是你传入的图片名称(tupianming)  args[0]是js文件名
登录后复制

javascript – Jasmine测试在Chrome和Firefox中传递,但在PhantomJS中失败

javascript – Jasmine测试在Chrome和Firefox中传递,但在PhantomJS中失败

我正在用React构建一个基本的博客应用程序.我正在使用Jasmine和Karma来进行我的前端测试.我开始运行第一个测试并通过Chrome(Chromium)和Firefox,但是当它在PhantomJS中运行时,我收到以下错误:
PhantomJS 1.9.8 (Linux 0.0.0) ERROR
  TypeError: 'undefined' is not a function (evaluating 'ReactElementValidator.createElement.bind(
          null,type
        )')
  at /home/michael/repository/short-stories/test/karma_tests/story_test.js:1742

我的测试文件如下所示:

var React = require('react/addons');
var Story = require('../../app/js/components/story.jsx');
var TestUtils = React.addons.TestUtils;
var testUtilsAdditions = require('react-testutils-additions');

  describe('Story component',function () {
    var component;

    beforeEach(function () {
      component = TestUtils.renderIntodocument(React.createElement('story'));
      component.props.storyTitle = 'front end test title';
      component.props.author = 'front end author';
      component.props.storyText = 'front end story text';
    });

    it('should display a story',function () {
      expect(component.props).tobedefined();
      expect(component.props.storyTitle).tobedefined();
      expect(component.props.storyTitle).toBe('front end test title');
      expect(component.props.author).toBe('front end author');
      expect(component.props.storyText).toBe('front end story text')
    });

  });

我尝试删除我的node_modules,npm缓存清除和npm安装,但它没有修复它.我不确定我的测试如何在Firefox和Chrome中传递,但不能在PhantomJS中传递.您可以在此处查看完整项目:https://github.com/mrbgit/short-stories.如果有更多信息可以提供帮助,请告诉我.任何帮助表示赞赏.谢谢!

解决方法

PhantomJS使用了一个相当旧版本的Qt-Webkit,它不提供 Function.prototype.bind.这对很多库来说都是一个问题,因此可以使用 polyfill NPM module called ‘phantomjs-polyfill’.

如果您不想使用NPM模块(如果您正在测试未与browserify / webpack捆绑在一起的浏览器站点),则在MDN页面上提供以下用于绑定的polyfill,您可以自己附加它:

if (!Function.prototype.bind) {
  Function.prototype.bind = function(oThis) {
    if (typeof this !== 'function') {
      // closest thing possible to the ECMAScript 5
      // internal IsCallable function
      throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
    }

    var aArgs   = Array.prototype.slice.call(arguments,1),fToBind = this,fnop    = function() {},fBound  = function() {
          return fToBind.apply(this instanceof fnop
                 ? this
                 : oThis,aArgs.concat(Array.prototype.slice.call(arguments)));
        };

    fnop.prototype = this.prototype;
    fBound.prototype = new fnop();

    return fBound;
  };
}

javascript – mocha init超时与mocha-phantomjs

javascript – mocha init超时与mocha-phantomjs

我有以下testrunner.html:
<html>
  <head>
    <title>Specs</title>
    <Meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="/content/css/mocha.css" />
    <script>
        function assert(expr,msg) {
            if (!expr) throw new Error(msg || 'Failed');
        }
    </script>

    <script src="/client/lib/require.js" type="text/javascript" data-main="/client/specs/_runner.js"></script>

  </head>
  <body>
    <div id="mocha"></div>
  </body>
</html>

_runner.js如下所示:

// Configure RequireJS
require.config({
    baseUrl: '/client',urlArgs: "v=" + (new Date()).getTime()
});

// Require libraries
require(['require','lib/chai','lib/mocha'],function (require,chai) {

    // Chai
    assert = chai.assert;
    should = chai.should();
    expect = chai.expect;

    // Mocha
    mocha.setup('bdd');


    // Require base tests before starting
    require(['specs/stringcalculator.specs'],function (person) {
        mocha.setup({ globals: ['hasCert'] });
        // Start runner
        if (window.mochaPhantomJS) {
            mochaPhantomJS.run();
        }
        else { mocha.run(); }
    });

});

StringCalculator.specs.js是这样的:

define(['app/model/StringCalculator'],function () {

    describe("StringCalculator",function () {

        describe("when an empty string is passed in",function () {
            it("returns 0",function () {
                var result = StringCalculator.add("");
                assert(result === 0);
            });
        });

        describe("when a number is passed in",function () {
            it("returns the number",function () {
                var result = StringCalculator.add("2");
                assert(result === 2);
            });
        });

        describe("when string is passed in",function () {
            it("returns NaN",function () {
                var result = StringCalculator.add("a");
                assert(isNaN(result));
            });
        });

        describe("when '1,2' is passed in",function () {
            it("returns 3",function () {
                var result = StringCalculator.add("1,2");
                assert(result === 3);
            });
        });
    });
});

这是StringCalculator.js本身(从摩卡样本):

define([],function() {
    window.StringCalculator = StringCalculator = {
        add: function(inputString) {
            if (inputString === '') {
                return 0;
            }

            var result = 0;
            var inputStrings = inputString.split(',');

            for (var i = 0; i < inputStrings.length; i++) {
                result += parseInt(inputStrings[i]);
            }

            return result;
        }
    }
});

当在浏览器中调用testrunner.html运行规范时,一切都按预期运行.
在OS X上运行mocha-phantomjs client / specs / testrunner.html时,会收到以下错误信息:

无法启动mocha:初始化超时

我可能在这里失踪?

我也试过mocha-phantomjs http://httpjs.herokuapp.com失败了同样的错误.

更新:
如果我打电话给mocha-phantomjs http:// localhost:81 / client / specs / testrunner.html我也在控制台上收到以下错误:

RangeError: Maximum call stack size exceeded.

http://localhost:81/client/lib/chai.js?v=123423553533535:2601
Failed to start mocha: Init timeout

解决方法

我得到的一样通过grunt-mocha-phantomjs npm包运行mocha-phantomjs时,无法启动摩卡错误.找到解决方案 here.

重复参考:

要运行mocha-phantomjs,更改

mocha.run();

if (mochaPhantomJS) {
  mochaPhantomJS.run();
}
else {
  mocha.run();
}

今天的关于javascript – PhantomJS崩溃 – 退出代码126js退出程序的分享已经结束,谢谢您的关注,如果想了解更多关于java – bash脚本出错“退出代码126”、javascript - 如何使用phantomjs获取截图并保存、javascript – Jasmine测试在Chrome和Firefox中传递,但在PhantomJS中失败、javascript – mocha init超时与mocha-phantomjs的相关知识,请在本站进行查询。

本文标签: