How to open a webpage in PowerShell and scroll down.
In fact, I am creating a script that will make a network report itself and provide the screenshot that I want. I can open the webpage and run the test using a script, but I want my script to scroll down so that I can take the correct screenshot. Please, help.
To be precise, I want my script to open testmy.net website and do a network report. I want to take a screenshot only for the report and crop everything else. I would really appreciate any help.
Q) How to scroll a web page in PS? Am I opening a website and I want to scroll down?
Q) How to take a screenshot of only a certain thing? (After some research, I got a part that could take a screenshot of the entire desktop)
I have attached a screenshot of the exact thing I need.

Script starts here:
$ie = new-object -comobject InternetExplorer.Application -property `
@{navigate2="http://testmy.net/SmarTest/combinedAuto"; visible = $true}
$ie.fullscreen = $true
do {sleep 5} until (-not ($ie.Busy))
[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
function screenshot([Drawing.Rectangle]$bounds, $path) {
$bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
$graphics = [Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
$bmp.Save($path)
$graphics.Dispose()
$bmp.Dispose()
}
$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, 1000, 900)
screenshot $bounds "C:\screenshot.png"
source
share