C # and selenium; Can I press the Windows key?

I would like to move the browser window left or right. I would manually press [WINDOW] + [LeftArrow] (or [RightArrow]) to achieve this.

I read this one, but it is for Java (see comments) , but I cannot find a way to press the Windows key when using C #.

My best option:

driver.Manage().Window.Position = new Point(x-coord, y-coord);
driver.Manage().Window.Size = new Size(myWidth,myHeight); 

but it seems a little strange, and I'm sure there is a better way.

I also tried:

Actions action = new Actions(driver);
action.SendKeys(Keys.   )

Then in Keys there is no Windows key ...

+4
source share
2 answers

SendKeys, , Windows, . Windows Strg + Esc. , Strg + Esc + Left ( , Windows 10), .

.

+4

dllatikay , . - Selenium:

 // Install-Package InputSimulator in package manager
 var inputSim = new InputSimulator();
 // WinKey + Up maximizes current focused window
 inputSim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.UP);
0

Source: https://habr.com/ru/post/1649650/


All Articles