0

I have used node to execute a shell script to open google chrome from terminal

The script is as follows

var sys = require('util');
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { 
    sys.puts(stdout) 
}
exec("google-chrome-stable 172.16.16.16/logout", puts);

My intention is to automatically submit the form that is loaded in the page, for which I need to use document.getElementById(). However node returns an error saying document is not defined. How do I proceed?

2
  • i didn't really see easy way. there's no API for external apps. Only for extensions. so your approach should be something like 1. run chrome with dev mode, register some extension which will work with some file and send commands via Commented Aug 17, 2016 at 14:47
  • and by the way why you trying to read rendered page? why not parse it by yourself? Commented Aug 17, 2016 at 14:50

1 Answer 1

3

You can't do anything inside Chrome programmatically after simply spawning it from a shell. You need to go through an API designed to drive the browser such as Phantom or Selenium.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.