How to Open and Manage Windows#
When you want to open multiple web pages in separate browser windows, Browserist makes it easy to organize and automate your workflow.
Basic Usage#
Let's imagine you want to open a web page first and then open another page in a new window, a basic example would look like this:
Python | |
---|---|
Multiple#
Opening Multiple Windows#
Normally, browsers allow you to open a new window by pressing Ctrl
+ N
in Windows or Cmd
+ N
on a Mac. With Browserist you can automate this, for example based on a list of URLs. This example will open each URL in a new window:
Python | |
---|---|
Closing a Window#
How to close the current tab or, if it's the last tab in a window, the current browser window:
Python | |
---|---|
Switching Between Windows#
Switching between windows is a common task when using a browser. Instead of either clicking a window to switch to it or using a keyboard shortcut to cycle through open windows, you can automate this with Browserist:
Python | |
---|---|
Now we can switch between each window by calling its handle:
Python | |
---|---|
Return to the Initial Window#
Browserist also keeps track of the initial tab of the original browser window, so you can easily switch back to it:
Python | |
---|---|
Get Handle ID of Current Window#
Under the hood, Browserist uses handle IDs to manage and identify open windows and tabs. You can get the handle ID of the current window to switch back to it later:
Python | |
---|---|
Example#
Get List of URLs from Open Windows#
Because a link can redirect to a different destination than the original URL, you sometimes want to capture the actual destination of each page. Here is an example of how to capture all the links from a web page and open them in new windows:
Python | |
---|---|
Position#
You can also control the position of the browser window on the screen. This can be useful when you want to automate the placement of windows on your screen.
Absolute#
How to move the window to the chosen coordinate of the screen, if possible:
Python | |
---|---|
Relative#
Get the current position of the window and move it by 10 pixels in both axes, if possible: