MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / SetActiveKeyboard

Method SetActiveKeyboard

dotnet/src/webdriver/Interactions/Actions.cs:93–106  ·  view source on GitHub ↗

Sets the active keyboard device for this Actions class. The name of the keyboard device to set as active. A self-reference to this Actions class. If a device with this name exists but is not a keyboard.

(string name)

Source from the content-addressed store, hash-verified

91 /// <returns>A self-reference to this Actions class.</returns>
92 /// <exception cref="InvalidOperationException">If a device with this name exists but is not a keyboard.</exception>
93 [MemberNotNull(nameof(activeKeyboard))]
94 public Actions SetActiveKeyboard(string name)
95 {
96 InputDevice? device = FindDeviceById(name);
97
98 this.activeKeyboard = device switch
99 {
100 null => new KeyInputDevice(name),
101 KeyInputDevice keyDevice => keyDevice,
102 _ => throw new InvalidOperationException($"Device under the name \"{name}\" is not a keyboard. Actual input type: {device.DeviceKind}"),
103 };
104
105 return this;
106 }
107
108 /// <summary>
109 /// Sets the active wheel device for this Actions class.

Calls

no outgoing calls