概要
テキスト以外の特殊キーのキーボード操作用クラス
オブジェクト設定
・変数宣言
Dim Keys As New Keys
・親クラス:WebDriver
文法
Keys.[メソッド]
メソッド・プロパティ
・メソッド
スクロールできます
Name | 解説 | Short Example |
---|---|---|
Enter | Enter | driver.SendKeys keys.Enter |
Return | Return | driver.SendKeys keys.Return |
Space | driver.ActiveElement.SendKeys Keys.Space | |
LeftAlt | Alt | driver.SendKeys keys.LeftAlt |
LeftControl | ctrl | driver.SendKeys keys.LeftControl |
LeftShift | Shift | driver.SendKeys keys.LeftShift |
Alt | Alt | elm.Click Keys.Alt |
Control | ctrl | driver.FindElementByName("q").SendKeys Keys.Control, "v" |
Shift | Shift | driver.ActiveElement.SendKeys Keys.Shift, Keys.Tab |
Tab | Tab | driver.ActiveElement.SendKeys Keys.Tab |
Escape | esc | driver.ActiveElement.SendKeys Keys.Escape |
Equal | = | driver.ActiveElement.SendKeys Keys.Equal |
Semicolon | ; | driver.ActiveElement.SendKeys Keys.Semicolon |
ArrowUp | ↑ | driver.SendKeys keys.ArrowUp |
ArrowDown | ↓ | driver.SendKeys keys.ArrowDown |
ArrowLeft | ← | driver.SendKeys keys.ArrowLeft |
ArrowRight | → | driver.SendKeys keys.ArrowRight |
Up | ↑ | driver.ActiveElement.SendKeys Keys.Up |
Down | ↓ | driver.ActiveElement.SendKeys Keys.Down |
Left | ← | driver.ActiveElement.SendKeys Keys.Left |
Right | → | driver.ActiveElement.SendKeys Keys.Right |
Backspace | Back | driver.SendKeys keys.Backspace |
Delete | Del | driver.ActiveElement.SendKeys Keys.Delete |
Home | Home | driver.SendKeys keys.Home |
End | End | driver.SendKeys keys.End |
Insert | Insert | driver.SendKeys keys.Insert |
PageDown | PageDown | driver.SendKeys keys.PageDown |
PageUp | PageUp | driver.SendKeys keys.PageUp |
Pause | Pause | |
Cancel | ||
Clear | ||
Command | command | |
Meta | ||
Null | ||
Help | ||
F1 | F1 | driver.SendKeys keys.F1 |
F2 | F2 | driver.SendKeys keys.F2 |
F3 | F3 | driver.SendKeys keys.F3 |
F4 | F4 | driver.SendKeys keys.F4 |
F5 | F5 | driver.SendKeys keys.F5 |
F6 | F6 | driver.SendKeys keys.F6 |
F7 | F7 | driver.SendKeys keys.F7 |
F8 | F8 | driver.SendKeys keys.F8 |
F9 | F9 | driver.SendKeys keys.F9 |
F10 | F10 | driver.SendKeys keys.F10 |
F11 | F11 | driver.SendKeys keys.F11 |
F12 | F12 | driver.SendKeys keys.F12 |
※Short Exampleは、動作確認ができたコードを記載しています。
メソッド(テンキー)
スクロールできます
Name | 解説 | Short Example |
---|---|---|
Add | + | driver.ActiveElement.SendKeys Keys.Add |
Subtract | - | driver.ActiveElement.SendKeys Keys.Subtract |
Multiply | * | driver.ActiveElement.SendKeys Keys.Multiply |
Divide | / | driver.ActiveElement.SendKeys Keys.Divide |
Decimal | . | driver.ActiveElement.SendKeys Keys.Decimal |
Separator | , | driver.ActiveElement.SendKeys Keys.Separator |
NumPad0 | 0 | driver.ActiveElement.SendKeys Keys.NumPad0 |
NumPad1 | 1 | driver.ActiveElement.SendKeys Keys.NumPad1 |
NumPad2 | 2 | driver.ActiveElement.SendKeys Keys.NumPad2 |
NumPad3 | 3 | driver.ActiveElement.SendKeys Keys.NumPad3 |
NumPad4 | 4 | driver.ActiveElement.SendKeys Keys.NumPad4 |
NumPad5 | 5 | driver.ActiveElement.SendKeys Keys.NumPad5 |
NumPad6 | 6 | driver.ActiveElement.SendKeys Keys.NumPad6 |
NumPad7 | 7 | driver.ActiveElement.SendKeys Keys.NumPad7 |
NumPad8 | 8 | driver.ActiveElement.SendKeys Keys.NumPad8 |
NumPad9 | 9 | driver.ActiveElement.SendKeys Keys.NumPad9 |
※Short Exampleは、動作確認ができたコードを記載しています。
Example
Chrome_Usekeys
Private Sub Chrome_Usekeys()
Dim driver As New ChromeDriver
Dim Keys As New Keys
driver.Get "https://www.google.co.jp"
driver.ActiveElement.SendKeys Keys.Equal
driver.Wait 2000
driver.ActiveElement.SendKeys Keys.Space
driver.Wait 2000
driver.ActiveElement.SendKeys Keys.Left
driver.Wait 2000
driver.ActiveElement.SendKeys Keys.Delete
driver.Wait 2000
driver.ActiveElement.SendKeys Keys.Semicolon
driver.Wait 2000
driver.ActiveElement.SendKeys Keys.Escape
driver.Wait 2000
driver.ActiveElement.SendKeys Keys.Tab
driver.Wait 2000
driver.ActiveElement.SendKeys Keys.Shift, Keys.Tab
driver.Wait 2000
Stop
driver.Quit
End Sub
confirm_keyboard
Private Sub confirm_keyboard()
Dim driver As New ChromeDriver
Dim keys As New keys
driver.AddArgument "--start-maximized"
driver.Get "https://www.onlinemictest.com/ja/keyboard-test/"
Dim TouchScreen As TouchScreen
Set TouchScreen = driver.TouchScreen
TouchScreen.Scroll 0, 300
driver.SendKeys keys.Return
driver.Wait 1000
driver.SendKeys keys.Enter
driver.Wait 1000
driver.SendKeys keys.LeftAlt
driver.Wait 1000
driver.SendKeys keys.LeftControl
driver.Wait 1000
driver.SendKeys keys.LeftShift
driver.Wait 1000
driver.SendKeys keys.Alt
driver.Wait 1000
driver.SendKeys keys.Up
driver.Wait 1000
driver.SendKeys keys.Down
driver.Wait 1000
driver.SendKeys keys.Left
driver.Wait 1000
driver.SendKeys keys.Right
driver.Wait 1000
driver.SendKeys keys.Backspace
driver.Wait 1000
driver.SendKeys keys.Home
driver.Wait 1000
driver.SendKeys keys.End
driver.Wait 1000
driver.SendKeys keys.Insert
driver.Wait 1000
driver.SendKeys keys.PageUp
driver.Wait 1000
driver.SendKeys keys.PageDown
driver.Wait 1000
Stop
driver.Quit
End Sub
function_keys
Private Sub function_keys()
Dim driver As New ChromeDriver
Dim keys As New keys
driver.AddArgument "--start-maximized"
driver.Get "https://www.onlinemictest.com/ja/keyboard-test/"
Dim TouchScreen As TouchScreen
Set TouchScreen = driver.TouchScreen
TouchScreen.Scroll 0, 300
driver.SendKeys keys.F1
driver.Wait 1000
driver.SendKeys keys.F2
driver.Wait 1000
driver.SendKeys keys.F3
driver.Wait 1000
driver.SendKeys keys.F4
driver.Wait 1000
driver.SendKeys keys.F5
driver.Wait 1000
driver.SendKeys keys.F6
driver.Wait 1000
driver.SendKeys keys.F7
driver.Wait 1000
driver.SendKeys keys.F8
driver.Wait 1000
driver.SendKeys keys.F9
driver.Wait 1000
driver.SendKeys keys.F10
driver.Wait 1000
driver.SendKeys keys.F11
driver.Wait 1000
driver.SendKeys keys.F12
driver.Wait 1000
Stop
driver.Quit
End Sub
Use_numerickeypad
Private Sub Use_numerickeypad()
Dim driver As New ChromeDriver
Dim Keys As New Keys
driver.Get "https://www.google.co.jp"
driver.ActiveElement.SendKeys Keys.Add
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.Subtract
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.Multiply
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.Divide
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.Decimal
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.Separator
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.NumPad0
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.NumPad1
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.NumPad2
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.NumPad3
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.NumPad4
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.NumPad5
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.NumPad6
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.NumPad7
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.NumPad8
driver.Wait 1000
driver.ActiveElement.SendKeys Keys.NumPad9
driver.Wait 1000
Stop
driver.Quit
End Sub