Private Sub Window_SetSize()
Dim driver As New ChromeDriver
Dim Win As selenium.Window
driver.Get "https://google.co.jp"
Set Win = driver.Window
Win.Maximize
driver.Wait 2000
Win.SetSize 800, 600
Debug.Print Win.Size.Width; Win.Size.Height
driver.Wait 2000
driver.Close
driver.Quit
End Sub
Window_Position
Private Sub Window_Position()
Dim driver As New ChromeDriver
driver.Get "https://google.co.jp"
Dim Win As selenium.Window
Set Win = driver.Window
Debug.Print Win.Position.X
Debug.Print Win.Position.Y
driver.Wait 2000
Win.SetPosition 200, 200
driver.Wait 2000
driver.Quit
End Sub
Windows_Switch
Private Sub Windows_Switch()
Dim Assert As New selenium.Assert
Dim driver As New ChromeDriver
driver.Get "https://the-internet.herokuapp.com/windows"
driver.FindElementByLinkText("Click Here").Click
driver.Wait 2000
driver.Window.SwitchToNextWindow
Assert.Equals "New Window", driver.Window.title
driver.Window.SwitchToPreviousWindow
Assert.NotEquals "New Window", driver.Window.title
driver.Window.SwitchToWindowByTitle "New Window"
driver.Quit
End Sub
Windows_SwitchByName
Private Sub Windows_SwitchByName()
Dim Keys As New Keys
Dim driver As New ChromeDriver
driver.Get "https://www.google.co.jp"
Dim hwnds As selenium.List
Set hwnds = driver.Send("GET", "/window_handles")
driver.FindElementByClass("MV3Tnb").Click Keys.Control
driver.Window.SwitchToNextWindow
driver.Wait 2000
driver.Window.SwitchToWindowByName hwnds.Item(1)
driver.Wait 2000
driver.Quit
End Sub
Windows_Close
Private Sub Windows_Close()
Dim driver As New ChromeDriver
driver.Get "https://the-internet.herokuapp.com/windows"
Dim winMain As selenium.Window
Set winMain = driver.Window
driver.FindElementByLinkText("Click Here").Click
Stop
Dim Win As selenium.Window
For Each Win In driver.Windows
If Not Win.Equals(winMain) Then Win.Close
Next Win
winMain.Activate
Stop
driver.Quit
End Sub