I am working on a solution for functional test with javascript support.
Naturally, using Symfony Framework, I choose Behat with Sahi driver, and I had my test suites green. The problem was that sahi is quite slow, and not stable enough and that is why I turn to PhantomJs as this blog post mentions: -> http://shashikantjagtap.net/running-behat-scenarios-with-pahntomjs/
Some of my tests stay green, but when I use $this->getSession()->getDriver()->evaluateScript()
, there is no return and I can't evaluate javascript.
If someone ever deal with and found a solution ...
++
You have not solved the problem? Try it:
$this->getSession()->getDriver()->evaluateScript(
"function(){ return 'some expression'; }()"
);
Inside your method you can use:
$result = $this->getSession()->evaluateScript("$('input').val();");
var_dump($result);
In my use case will return the value of the first input tag in the code. As you see, you can use jQuery if you have it in your page.
the "Scenario" must run with the tag @javascript
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With