Set browser window position puppeteer - node.js

Is it possible to move the position of the browser window?
As in selenium driver.set_window_position(-10000, 0)
Setting the browser position at startup is not suitable, it is necessary during operation

Related

how to get website's site from chrome extension

I am using this code for the Chrome extension to get the window's width in the background script
chrome.windows.getCurrent(function (wind) {
const w = wind.width;
});
but that sizes the entire window. If I have open and nested the devtools, it will be inside that window.
How can I instead get the size of only the website's width?

detect when window size changed

I am making a web browser with gtk-rs. I am trying to do a check for fullscreen. I can get the screen size and compare that to the window size, if they are the same it is in fullscreen and I can hide the unnecessary widgets. Though this works, I can only get it to work when I bind it some key event (so when I press a key it will check if the window and screen sizes are the same again). I want to be able to get this to work by simply noticing the window size has changed.

Make Chrome Extension Browser Action Popup bigger than browser window

In FireFox extensions, the Panel/Popup that opens on the Toolbar sizes itself outside the browser window, if needed, so that we see every populated elements in the panel. In Chrome however, the popup/panel is only drawn until the browser window's boundaries. So, if the user resizes the browser window small enough, you don't see the entire popup.
I checked the documentation and couldn't find anything. Is there anything that can be done to show the entire popup?
This seems to be OS-dependent (can be reproduced on Linux and Win7, but not Win10).
As an extension author, there is nothing you can do to control it, this is just how the browser renders its content. You could submit a bug report.

How to reset browser's scroll state between page reloads?

The default behavior for browsers on page reload is to scroll back to the position where you last were on the page.
Let's say you scrolled to features section and then you hit F5. The browser will reload the page but it will remember the position you were at and scroll to features section.
Does anyone know how to reset this scroll state in browsers? In my application I need the browser to load page naturally and position the page on top on every page refresh.
There is not something that you can "configure" to avoid that behavior because that's the browser behavior.
What you can do is to add a simple javascript when the page has been loaded to scroll to the top (if you already are on the top, this will do nothing):
window.scrollTo(0, 0);
To know when the page has been loaded, you can use jQuery document on load functionality if you are using jQuery, the equivalent on your javascript framework or the body onload property to place a function that execute the above code.

Does Selenium require maximized browser window?

I have not used Selenium myself, but I was wondering whether the browser window needs to be maximized during test execution? I have used some other tools where the mouse pointer does not find the correct HTML element if the window is too small.
Selenium 2.0 (WebDriver) automatically attempts to scroll an element into view when you're going to perform any action on this element. If it can't scroll it throws an exception. So, don't make your window too small, but there is no need to maximize it. Keep it "mid-size".
For the abovementioned reason, you may want to maximize the browser window to avoid excessive scrolling, that can cause some unnecesssary events on the page.
Sometimes Selenium (WebDriver) can't click an element if it is placed too close to the viewport border (half-visible). In this case you can try to tune the window size to make this element either totally visible, or totally invisible (to activate auto-scrolling).
If you use Selenium (WebDriver) with "native events" enabled, you'd better keep the browser window in foreground and in focus during test execution. No matter whether it is maximized or "mid-size" -- just don't minimize it!
If you're happy with "synthesized events" -- many chances for your tests to run successfully in foreground.
No, because Selenium uses the DOM Structure to act on and not the OS(mouse, windows and stuff). You can actually minimize your window during a test.
Maybe not maximized, but probably best to have test at set minimum and maximum size.
An idea would be to have selenium resize the window for you before it runs the tests... A quick search gave me this: https://makandracards.com/makandra/9773-how-to-start-selenium-browser-with-custom-window-size

Resources