Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle new window? #804

Closed
overflowz opened this issue Sep 23, 2016 · 3 comments
Closed

How to handle new window? #804

overflowz opened this issue Sep 23, 2016 · 3 comments

Comments

@overflowz
Copy link

overflowz commented Sep 23, 2016

I need to access new window from nightmare and manipulate it as I do in main window. Is that even possible?

nightmare
  .goto('http://website.com/')
  .click('button[id="mybutton"]') // this actually opens new window/tab whatever.
  .type('input[type="text"]', 'hello world') // I want this to happen on new window, how?
  .then(function () { console.log('all done'); })
  .catch(function (err) { console.log(err); });

basic html:

<button id="mybutton" onclick="javascript:window.open('http://website.com/', '_blank');">click me</button>
<input type="text"></input>

EDIT: Don't get me wrong, I've searched same questions here, but isn't there any workaround? If not, can I just block opening new window and load the new page into the current one?

EDIT2: I've noticed, that if you specify show: false opening new tab/window is shown by default. Any thoughts about this? It's getting annoying though.

@rosshinkley
Copy link
Contributor

Out of the box? no. Dealing with multiple instances of BrowserWindow isn't currently supported in Nightmare. (Memory serving, it's one of the features talked about for a future version in #593.)

You can kind of skirt this issue now, but it depends largely on what you need. I'd suggest checking out nightmare-window-manager. It's limited, but might be enough to help you skate by.

@overflowz
Copy link
Author

Thanks for the reply! I've tried nightmare-window-manager too, but still I'm facing second issue. no matter if I specify show: false new window always opens up visible.

@rosshinkley
Copy link
Contributor

Moving this to nightmare-window-manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants