0

I have a page with a frame in it. the frame is loaded from the same (currently: localhost) server. however, after the frame is loaded, the page suppose to load a content into that frame (happens in every browser) but it is not happening in casper.

I'll list it in simple steps:

  1. Page loading
  2. Frame loading
  3. page loading content into the frame

This last step, step 3 is what missing. waiting for 5 seconds didn't help, every screen capture is coming back empty where the frame is.

I've used withFrame method, and I did get the frame, but it won't fill (got the loaded code, not the full code that appears after in every browser).

After using error checking, it seems that casper does not recognize the bind() method. I've tried to inject a bind prototype like so:

    if (!Function.prototype.bind)
    {
        console.log('bind injecttor 1');
        Function.prototype.bind = function (oThis)
        {
        console.log('bind injecttor 2');
        if (typeof this !== "function")
        {
            console.log('bind injecttor error');
            // 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 && oThis
                    ? this
                    : oThis,
                aArgs.concat(Array.prototype.slice.call(arguments)));
            };

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

        console.log('bind injected.');
        return fBound;
        };
    }

Now, I got the first log, but none of the others. any ideas?

donald
  • 489
  • 5
  • 13
  • You should check if there are errors with [page.error](http://docs.casperjs.org/en/latest/events-filters.html#page-error) and remote.message – Artjom B. Jun 08 '14 at 08:36
  • Thanks! I didn't think about this option. Seems that casper does find an error. problem is - it doesn't appear in any other browser (chrome, FF, even explorer). something to do with bind. I'll update the question! – donald Jun 08 '14 at 10:27
  • Looks like `bind` is not supported, try http://stackoverflow.com/a/16866162/1816580 – Artjom B. Jun 08 '14 at 10:48
  • Yes indeed. Thing is - I didn't find a way to inject the `bind()` function. I've updated the question, thanks! – donald Jun 08 '14 at 11:40
  • How are you injecting the bind prototype? (Add the code to your question) – berrberr Jun 09 '14 at 15:35
  • Yes, and the code is in the question including the results I get: This fill is added, but the function biner doesn't work – donald Jun 09 '14 at 18:00
  • No, I mean what is the line you are using to inject that bind method override code into casper? Are you using `clientScripts` when creating the casper object? Are you using `evaluate`? My guess right now is that you are injecting your bind override after the bind is actually called (which would explain why you see the first console message and not others) – berrberr Jun 09 '14 at 20:07
  • I'm using clientScripts. sorry. – donald Jun 09 '14 at 23:44
  • When is the call being made to `bind` on the page that you are testing? Also could you post a sample of your test (particularly the area that invokes something that calls `bind`)? – berrberr Jun 10 '14 at 15:09
  • possible duplicate of [CasperJS bind issue](http://stackoverflow.com/questions/25359247/casperjs-bind-issue) – Artjom B. Mar 28 '15 at 13:54

0 Answers0