vendredi 30 octobre 2015

PhantomJS does not run JavaScript code

I'm using Laravel with Vagrant. I need to run acceptance test using Codeception and PhantomJS. Everything seems to be fine except running JS code.

I have a registration form that uses a little JS code to prevent robots from registration:

<script type="text/javascript">
        $(function() {
            $('.form-horizontal').append('<input type="checkbox" name="human" value="1" checked="checked">');
        });
    </script>

This is what I do.

1) I run phantomjs:

B# phantomjs --webdriver=5555

2) Start acceptance test:

vendor/bin/codecept run acceptance RegisterCept

Of course test fails because PhantomJS does not execute JS code and without it registration can not be completed. What am I doing wrong? Config file:

class_name: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: http://localhost
            browser: phantomjs
            port: 4444
            capabilities:
                javascriptEnabled: true
                webStorageEnabled: true
                unexpectedAlertBehaviour: 'accept'
        - Laravel5:
            environment_file: .env.testing
        - \Helper\Acceptance

I'm using Travis. Test also fails. My .travis.yml:

language: php
php:
  - 5.5
  - 5.6

services: postgresql

addons:
  postgresql: "9.3"

install:
  - composer install

before_script:
  - cp .env.testing .env
  - php artisan migrate --seed --env="testing"
  - php vendor/bin/codecept build
  - phantomjs --webdriver=4444 2>&1 >/dev/null &
  - sleep 5

script: php vendor/bin/codecept run



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire