'How can I open a link in Chrome from Photoshop to download an image?

I'm creating a script in Photoshop using JavaScript that I want to open chrome for all types of windows users and open a link in chrome. After the chrome is open and link is insert I want to complete a form with values that I know and submit the form, the new link that is generated I want to open and download the image.

Using my code the error I received on Photoshop is "the window is undefined", but if I delete window.open line the chrome open using the script in Photoshop.

Here is my code. Any solutions?

var commandtoRun = "C:\\PROGRA~1\\Google\\Chrome\\Application\\chrome.exe"; 
app.system(commandtoRun,"","","open","1");
var windowObjectReference;

window.open( 
    "https://www.yourURL.com", "_blank");

I did it with

window.onload = function() {
    window.open("https://www.w3schools.com");
}
//openRequestedPopup();

//file.remove();  
var site="//mylinkwithform"; //your side

      if (  $.os.indexOf("Windows") != -1 ) 

      {//SYSTEM IS ONE OF THE WINDOWS
                          app.system("cmd.exe /c\"start http://"+site+"\"" );
                }
                          else{//MUST BE MAC
                          system.callSystem("open http://"+site);
          }

How i insert the values in the form from the site and submit the form?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source