2014-10-05 12 views
7

sto iniziando la mia avventura con Goniometro & Jasmine & PhantomJS. Quello che volevo ottenere è usare PhantomJS per eseguire i test da ProtractorDemo. Ma ho fallito, e non so perché. Dove sono passaggi esatti:L'impostazione di PhantomJs con Goniometro non funziona

Ho installato goniometro-demo (https://github.com/juliemr/protractor-demo)

git clone https://github.com/juliemr/protractor-demo.git 
cd protractor-demo 
npm install 

phantomjs Poi ho installato:

npm install --save-dev phantomjs 

configurazione Poi ho aggiornato (sulla base di http://angular.github.io/protractor/#/browser-setup):

capabilities: { 
    'browserName': 'phantomjs', 

    /* 
    * Can be used to specify the phantomjs binary path. 
    * This can generally be ommitted if you installed phantomjs globally. 
    */ 
    'phantomjs.binary.path':'./node_modules/phantomjs/bin/phantomjs', 

    /* 
    * Command line arugments to pass to phantomjs. 
    * Can be ommitted if no arguments need to be passed. 
    * Acceptable cli arugments: https://github.com/ariya/phantomjs/wiki/API-Reference#wiki-command-line-options 
    */ 
    'phantomjs.cli.args':['--logfile=PATH', '--loglevel=DEBUG'] 
} 

Il file di configurazione completo è simile a questo:

// Tests for the calculator. exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', 

    specs: [ 
    'spec.js' ], 

    capabilities: { 
     'browserName': 'phantomjs', 

     /* 
     * Can be used to specify the phantomjs binary path. 
     * This can generally be ommitted if you installed phantomjs globally. 
     */ 
     'phantomjs.binary.path': './node_modules/phantomjs/bin/phantomjs', 

     /* 
     * Command line arugments to pass to phantomjs. 
     * Can be ommitted if no arguments need to be passed. 
     * Acceptable cli arugments: https://github.com/ariya/phantomjs/wiki/API-Reference#wiki-command-line-options 
     */ 
     'phantomjs.cli.args': ['--logfile=PATH', '--loglevel=DEBUG'] } }; 

comandi Poi ho eseguito da esercitazione:

.\node_modules\.bin\webdriver-manager update 

ho iniziato WebDriver e web server:

.\node_modules\.bin\webdriver-manager start 
npm start 

L'output di questo comando è stato:

Using the selenium server at http://127.0.0.1:4444/wd/hub 
Server running at http://localhost:3456 

E passaggio finale:

node_modules\.bin\protractor test\conf.js 

e la finestra altra console WebDriver-manager modulo di uscita è stata:

15:23:10.181 INFO - Executing: [new session: Capabilities [{phantomjs.binary.path=./node_modules/phantomjs/bin/phantomjs, count=1, browserName=phantomjs, phantomjs.cli.args=[--logfile=PATH, --loglevel=DEBUG]}]]) 
15:23:10.192 INFO - Creating a new session for Capabilities [{phantomjs.binary.path=./node_modules/phantomjs/bin/phantomjs, count=1, browserName=phantomjs, phantomjs.cli.args=[--logfile=PATH, --loglevel=DEBUG]}] 
15:23:10.203 INFO - executable: d:\dev\protractor-demo\.\node_modules\phantomjs\bin\phantomjs 
15:23:10.203 INFO - port: 44410 
15:23:10.203 INFO - arguments: [--logfile=PATH, --loglevel=DEBUG, --webdriver=44410, --webdriver-logfile=d:\dev\protractor-demo\phantomjsdriver.log] 
15:23:10.204 INFO - environment: {} 

ma non succede nulla. Non vedo risultato di test eseguiti. C'è qualcosa che mi manca? Quando cambio il browser da phantomjs a chrome, vedo i risultati dei test.

+0

Looks correlati: [prova di goniometro sul phantomjs con l'uso di vaso autonomo di selenio,] (http://stackoverflow.com/q/26096786) –

+0

Grazie. Comunque, i miei passi sono corretti? Perché in seguito ho trovato un esempio in cui è sufficiente avviare PhantomJS come Remote WebDriver e, quando mi collego a questo driver utilizzando seleniumAddress, funziona. Non ho capito bene. – dragonfly

+0

Non lo so, non l'ho mai fatto. –

risposta

4

In realtà non c'è bisogno di correre:

.\node_modules\.bin\webdriver-manager update 

né:

.\node_modules\.bin\webdriver-manager start 

Invece si potrebbe iniziare un autista fantasma con il seguente comando (9515 sarà il porto in cui il autista verrà eseguito) eseguendo:

phantomjs --webdriver=9515 

in aggiunta ad esso si dovrebbe modificare il file di configurazione in modo da permettere goniometro sapere wh prima che l'autista venga trovato Per il vostro caso, il file di configurazione dovrebbe apparire come il seguente:

exports.config = { 
    seleniumAddress: 'http://localhost:9515', 

    specs: ['spec.js'], 

    capabilities: { 
     'browserName': 'phantomjs', 

     /* 
     * Can be used to specify the phantomjs binary path. 
     * This can generally be ommitted if you installed phantomjs globally. 
     */ 
     'phantomjs.binary.path': './node_modules/phantomjs/bin/phantomjs', 

     /* 
     * Command line arugments to pass to phantomjs. 
     * Can be ommitted if no arguments need to be passed. 
     * Acceptable cli arugments: https://github.com/ariya/phantomjs/wiki/API-Reference#wiki-command-line-options 
     */ 
     'phantomjs.cli.args': ['--logfile=PATH', '--loglevel=DEBUG'] 
     } 
}; 

E allora si sarà in grado di eseguire i test eseguendo:

node_modules\.bin\protractor test\conf.js 
+0

Hai trovato questo lavoro con angular-cli – Wungsow