Closed giggioz closed 9 years ago
I have the same requirement.
I'd need to be able to click on a link that calls a JavaScript function; amongst other things this function generates a URL and pops it up in a new window.
I see PhantomJS has the ability to do this, added in this PR
Due to the lack of answers i moved to casperjs, it solved all the problems i had and it works nicely. You can write clean code avoiding callback hell.
Concerning this single issue in casperjs you can interact with a pop up window with e specific method, look here http://docs.casperjs.org/en/latest/modules/casper.html#waitforpopup
Hope this helps.
Thank you! I'll try Casper out too :)
Still no answer. I guess I'll have to try Casper too.
sorry fellas, been slammed but will get to this on the coming weekend i hope
okay, thank you.
Based on your response I can only assume that it's currently not a feature of the api?
Any word on this feature? Due to the pages I have to scrape, it's a make-or-break for me.
@reinpk Can the feature to interact with new window be added to v2?
not sure yet, great question though. we'll need to dig into the electron documentation to figure it out
i don't believe this is possible in electron, so i'm going to close this as not possible unfortunately. if you have an example of a popup script would be great to test it out though
@reinpk that's too bad. I was hoping for this feature to come now with v2 out.
I wish I understood more on how you are using electron in place of phantomjs. Maybe then I would understand why you say that you don't think it's possible.
Any chance you can explain at a high level how you are using electron? It's my understanding that electron is used to package applications...
Nevermind I think I found the answer in your readme. It appears you are using electron to create a new browser window and subsequently navigate the web. Very cool.
Maybe there is a way to force input buttons that a given website tries to open a new window so that they open in the current page. Anybody have any ideas?
@reinpk BrowserWindow.getAllWindows() returns an array of all the BrowserWindow object references. Surely this could be used to incorporate some sort of interaction with newly generated windows.
cc @matthewmueller
I tried what @bchr02 said "BrowserWindow.getAllWindows()" and this workaround works.
@bchr02 @devilpreet could you please paste a code sample of how you guys made this work? Thanks!
I wanted to get the newly opened window URL and heres how I got it working
const BrowserWindow = require('electron').BrowserWindow;
var wins = BrowserWindow.getAllWindows();
console.log("BW All Length: " + wins.length);
//Last one will be the newly opened window
var url = wins[wins.length - 1].webContents.getURL();
console.log("URL: " + url);
//The parent window
var url2 = wins[0].webContents.getURL();
console.log("URL: " + url2);
Hi,
i have a Nightmare instance in which i click a button that opens a new window.
Is there a way to handle the DOM of the new window? (for example typing the inputs, clicking buttons...)
Thanks.