Issue
As I'm Trying to open a web page in Microsoft Edge in Device Emulation mode. Is there any bat Script or PowerShell Script to open the web page in Device emulation in Microsoft Edge ?
Or if I open a web page on the Microsoft Edge is there any possibility to get the current tab using PowerShell and we can navigate using manual method that supposed to implemented in PowerShell.
eg : if I press f12 dev toll is launched and need to select the Toggle Device Emulation. This need to be Scripted. Is there any possibilities ?
Solution
You can use PowerShell to open an Edge window, then use SendKeys
to perform keystroke to open F12 dev tools and Toggle Device Emulation (Ctrl+Shift+M).
You can refer to the following sample code:
[system.Diagnostics.Process]::Start("msedge","https://www.bing.com/")
Sleep 3
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('Bing- Microsoft Edge')
Sleep 1
$wshell.SendKeys('{F12}')
Sleep 1
$wshell.SendKeys('^+{M}')
Answered By - Yu Zhou Answer Checked By - Candace Johnson (WPSolving Volunteer)