javascript - How to check the current status of the selenium server (API with Node.js? Something else?) -


i using node.js , selenium build automated tests. so, when starting script in 1 terminal, use commander open terminal , start selenium when launch automated tests. when want testing safari:

if(myargs.indexof("local_saf") != -1) {   console.log('starting selenium');         /* use commander open shell script opens terminal , starts selenium */         exec('open -a terminal.app startseleniumforsafari.sh',             function (error, stdout, stderr) {                 console.log('stdout: ' + stdout);                 console.log('stderr: ' + stderr);                 if (error !== null) {                      console.log('exec error: ' + error);                 }             });         wait(2500);          console.log('selenium should started');         /* selenium webdriver executable safari*/         safari = require('selenium-webdriver/safari');         browserundertest = new webdriver.builder()         .forbrowser('safari')         .usingserver('http://localhost:4444/wd/hub')         .build();     }     /*          not code.  came         https://stackoverflow.com/questions/14226803/javascript-wait-5-seconds-before-executing-next-line         , simple enough understand, , suited purposes.         */     function wait(ms){         var start = new date().gettime();         var end = start;         while(end < start + ms) {             end = new date().gettime();         }     } 

rather have wait time , print console 'selenium should started', i'd somehow detect has indeed started, or if there error.

is there way check current status of selenium server if launched in terminal?

i know calling http://localhost:4444/wd/hub/status result in response json {"state":"success","sessionid":null,"hcode":1982803459,"value":{"build":{"version":"2.52.0","revision":"4c2593c","time":"2016-02-11 19:06:42"},"os":{"name":"mac os x","arch":"x86_64","version":"10.12.6"},"java":{"version":"1.8.0_121"}},"class":"org.openqa.selenium.remote.response","status":0}

but know neither how that, nor once gotten.

i not have experience selenium or commander there might better solution, may of or point in right direction.

for one, should able make curl request, like: curl http://localhost:4444/wd/hub/status

it possible send messages , forth between processes, described here.

you play around premise, so:

from parent:

const child_process = require('child_process');  let options = {     stdio: [process.stdin, process.stdout, process.stderr, 'pipe', 'pipe'] };  let child = child_process.spawn('command', ['parameters', 'here'], options);  child.stdio[3].write('a message new terminal'); child.stdio[4].pipe(process.stdout); 

from child process:

const fs = require('fs'); fs.createwritestream(null, {fd: 4}).write('a message new terminal.'); 

--
also, npm package seems might solve problem you:

https://www.npmjs.com/package/wd


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -