alwex/php-casperjs

how to send value from casper to php variable?

Closed this issue · 1 comments

example this is my code:

public function get_iframe_name($class)
{
$fragment = <<<FRAGMENT
casper.then(function() {
var iframe_name = this.evaluate(function() {
var x = document.getElementsByClassName('$class');
return x[0].name;
});
console.log(iframe_name);
});

FRAGMENT;

    $this->_script .= $fragment;

    return $this;
}

I would like to get the value of iframe_name. I actually need the value to use on the next function to access the iframe, because that value is dynamic.

alwex commented

I don't think there is a way to use intermediate returns from casperjs as it is all executed in a separate process and php is not able to interact with the JS process during it's execution.
I think you should add a custom selector on the iframe or to use another kind of CSS selector to achieve it like "body > iframe"