How to check the number of open browser windows using Puppeteer? - puppeteer

I have an open browser window where the user clicks a button and after that, a new browser window opens with a new page.
How can I check that there are two browser windows open and not two pages?
The browser.browserContexts() property does not work, because if a new browser window is opened after clicking on another browser window, then these two browser windows have the same context.

Related

Running Chrome in app mode with multiple tabs?

So I have set up an app shortcut for YouTube in Chrome. When I click this, I get a new window that opens to YouTube's website. Works great. However, if I want to for example open videos in a new tab, these will be redirected to my main Chrome window, which is not what I want as I would rather have them as tabs in the YouTube app window.
Is this possible with some flag?

How to toggle Device Mode on a popup window in Chrome?

I have a web app with a chat that opens in a new popup window. Normally, in Chrome I can hit F12 and click the icon of a smart phone to toggle it. But in the popup window this icon does not appear. This is important for me since I need to throttle the connection of the popup in order to simulate a user disconnecting from the chat.
Thanks!
It doesn't seem to be currently possible. I've opened a ticket for you. Meanwhile you have couple of options:
open popup in a regular window (copy paste the url, or modify window.open call to open a new tab instead of a separate window),
create a Chrome extension that uses debugger API to send emulateNetworkConditions message to your popup window
or try hacking DevTools like so:
open DevTools (A) for your popup
focus on DevTools window and open another DevTools (B) for that window using a keyboard shortcut (F12/alt+cmd+J)
in the console of the DevTools B call WebInspector.overridesSupport.setEmulationEnabled(true) (to enable emulation) and then WebInspector.overridesSupport.settings.networkConditions.set({throughput: 1.5 * 1024, latency: 40}); (to enable network throttling)
Perhaps easier way as of today is to install chrome extension which will allow you to open preview in new tab instead of popup. There you can have the same icon to toggle to mobile. Below is the extension:
https://chrome.google.com/webstore/detail/tag-assistant-companion/jmekfmbnaedfebfnmakmokmlfpblbfdm?hl=en

How can I get local web pages to always open in a new window in XP?

I am running windows XP 2003 sp3. Ie is the default browser. If I have a web page open and then open a local web page it will always open it in the existing window. I want local web pages and url shortcuts to always open in a new window. How can I do this?
Somehow I don't think you are asking for programming help but I'm going to respond appropriate to the forum. Use the target attribute on your links to force browser window/tab actions. Valid standard options are: _self, _blank, _top, _parent. Use _blank to force the link to open in a new tab/window as per the default behaviour you have setup in IE.
Example
I don't think this can be done. The thing is windows XP will tend to open any local web page files and its shortcuts with the "Default Programs" that's mapped to that file type. So in your case, the IE being the default browser program, it opens in a new tab.
The same file will open up starting IE if there isn't any instance of IE already running. So I think the simple way to do your need is to have another IE instance running, and drag-drop the file you wan't to open into the IE window, which will open it.
P.S: other browsers like chrome allows dragging the tab outside the window to open up in a different window.

JavaFX redirect to web page

Does anyone know a simple way to get, for example, a button action event within a web deployed java fx application to direct the browser to a new web page?
So in my application I want to go to the home page of my website when the user clicks a javafx button.
I think this can be done with javascript & javafx, but i think it is messy......
application.getHostServices().showDocument("http://www.mywebsite.org");
hostServices.showDocument(uri)
Opens the specified URI in a new browser window or tab. The
determination of whether it is a new browser window or a tab in an
existing browser window will be made by the browser preferences. Note
that this will respect the pop-up blocker settings of the default
browser; it will not try to circumvent them.

How to open html link in a new window instead of a new tab on Firefox and Chrome?

My links correctly open a new window when using IE8; but when I use Firefox or Chrome, they just open a new tab.
I am using the code target="_blank" for my links.
How do I fix this so it opens a new browser window and not just another tab?
This fix needs to be for everyone that views the page and not just for my personal use.
It is there with the browser, because they supports tabbing, it will open in a tab. Having said that, there are probably some settings for them in each browser as well as addons that control that, for example, in firefox, you can control window positioning, tabs and a lot more with Tab Mix Plus addon.
Note that you can also open in new window with window.open eg:
window.open('example.html', 'name', 'settings')