One would think that this should be an easy thing to do, but I cannot find a way to detect whether the Chromium Edge Selenium webdriver Window is minimized or not in Powershell.
Specifically, the size and position of a Window seems to be the same regardless of whether or not it is in a maximized or minimized state. For example, take the following example (starting from a normal non-minimized window state):
> $driver.manage().Window.size
IsEmpty Width Height
------- ----- ------
False 1050 708
> $driver.manage().Window.position
IsEmpty X Y
------- - -
False 13 18
> $driver.manage().Window.minimize()
> $driver.manage().Window.size
IsEmpty Width Height
------- ----- ------
False 1050 708
> $driver.manage().Window.position
IsEmpty X Y
------- - -
False 13 18
As you can see, the Window size and position remain the same even though the Window has been minimized.
I can't find a isMinimized()
method or something similar anywhere either.
The Chromium Edge webdriver version is 93.0.961.38.
Any ideas?
You can try to execute JavaScript using the Selenium driver to get the size of the viewport (no powershell but in our scenarios work).
const width = window.innerWidth || document.documentElement.clientWidth ||
document.body.clientWidth;
const height = window.innerHeight|| document.documentElement.clientHeight||
document.body.clientHeight;
Reference:
Get the size of the screen, current web page and browser window
With powershell access WindowVisualState of the process:
Add-Type -AssemblyName UIAutomationClient
$prList = Get-Process -Name "notepad"
$prList | % {
$ae = [System.Windows.Automation.AutomationElement]::FromHandle($_.MainWindowHandle)
$wp = $ae.GetCurrentPattern([System.Windows.Automation.WindowPatternIdentifiers]::Pattern)
echo "Window visual state: $($wp.Current.WindowVisualState)"
}
Result:
Window visual state: Minimized
Reference:
Get window state of another process