Anuraag Baishya
Anuraag Baishya

Reputation: 884

Read page open in browser using JavaScript

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?

Upvotes: 0

Views: 57

Answers (1)

Quentin
Quentin

Reputation: 943108

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.

Upvotes: 3

Related Questions