JavaScript ChaiJs not present on window in Phantomjs-node injectJS

I'm trying to inject some scripts into a page that I'm loading into PhantomJs using the phantomjs-node bridge.

When I inject MochaJs into the page, I can evaluate and the window.mocha object is available. But when I inject chaiJs, the window.chai object isn't available.

I've verified that the injectJs call passes a true status into the callback, indicating that the script was successfully injected, and I've also verified that window.chai and window.mocha are available immediately after injection in a plunker here: http://plnkr.co/edit/gMzjavJqpNDNeYipmBHG?p=preview

I even tried using page.includeJs('http://cdnjs.cloudflare.com/ajax/libs/chai/1.10.0/chai.min.js') to ensure there wasn't a diff in the cloudflare cdn version and the npm install version I have, still isn't working.

What am I doing wrong?

page.injectJs(nodeLibDir + '/chai/chai.js', function(){
                //page.injectJs(nodeLibDir + '/mocha/mocha.js', function(){
                    page.evaluate(function(){
                        //window.callPhantom(window.mocha.constructor.name);
                        window.callPhantom(window.chai.version);
                    }, function(){
                        console.log('finished');
                        page.close();

                        res.json({status: status});
                        res.end();
                    });

                });
Answer:1

I am facing difficulty to bind jstree with an on-expand/on-collapse event. I am currently binding the jstree with selected_node event like this : $(function () { $("#tree").jstree({ "json_data" : { ...

I am facing difficulty to bind jstree with an on-expand/on-collapse event. I am currently binding the jstree with selected_node event like this : $(function () { $("#tree").jstree({ "json_data" : { ...

  1. bind jstree
  2. binding jstree with database in asp.net mvc

Recently we opened up sentry in a way to capture JS errors. The problem we noticed is that a lot of errors came back in other languages. We threw the error messages into google translate they looked ...

Recently we opened up sentry in a way to capture JS errors. The problem we noticed is that a lot of errors came back in other languages. We threw the error messages into google translate they looked ...

This is my code: var url = f.href.value; ed.dom.setAttribs(e, { href : 'javascript:void(0)', onclick: 'doSomething(' + url + ')' }); And the doSomething method: function doSomething(url) { ...

This is my code: var url = f.href.value; ed.dom.setAttribs(e, { href : 'javascript:void(0)', onclick: 'doSomething(' + url + ')' }); And the doSomething method: function doSomething(url) { ...

  1. passing parameters function javascript
  2. passing parameter function c++
  3. passing parameter function in r
  4. parameter passing function
  5. parameter passing function in php
  6. parameter passing functions python
  7. passing function parameter pointer
  8. parameter passing function call
  9. parameter passing function call in c
  10. passing parameter to function in shell script
  11. passing parameter to function in powershell
  12. passing parameter to function react
  13. passing parameter to function in jquery
  14. passing parameter to function in sql server
  15. passing parameter to function in bash
  16. passing parameter to function in reactjs
  17. passing parameter to function in unix
  18. passing parameter to function in vba
  19. message passing parameter function
  20. passing parameter to function type

When I am trying to do this: var element_current_classes=($("#form_div :textarea").attr('class')); or this: var element_current_classes=($("#form_div :select").attr('class')); I am getting this ...

When I am trying to do this: var element_current_classes=($("#form_div :textarea").attr('class')); or this: var element_current_classes=($("#form_div :select").attr('class')); I am getting this ...

  1. find elements inside element selenium
  2. find elements inside iframe
  3. find elements inside div jquery
  4. find elements inside div javascript
  5. find elements inside iframe jquery
  6. find elements inside iframe selenium
  7. find all elements inside a div jquery
  8. find elements inside element selenium python
  9. jquery find elements inside parent
  10. selenium find elements inside div
  11. jquery find elements inside
  12. jquery find elements inside container
  13. how to find elements inside a frame using selenium
  14. javascript find elements inside element
  15. protractor find elements inside element