Created
June 25, 2014 08:43
-
-
Save dck-jp/70f0056ba50d0660135d to your computer and use it in GitHub Desktop.
SeleniumVBA SwitchToWindow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub SwitchWindowTest() | |
Dim driver As New WebDriver | |
Call driver.Start("firefox", "http://www.red.oit-net.jp/") | |
Call driver.get("/tatsuya/java/winopen.htm") | |
Dim beforeHwd As String | |
beforeHwd = driver.WindowHandle 'Returns the handle of the current window. | |
driver.findElementByCssSelector("table.waku:nth-child(13) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(1) > form:nth-child(3) > input:nth-child(1)").click | |
Dim Hwds | |
Hwds = driver.WindowHandles ' Returns the handles of all windows within the current session. | |
Dim window: For Each window In Hwds | |
If window <> beforeHwd Then | |
driver.switchToWindow window | |
driver.get "/" | |
driver.Close | |
End If | |
Next | |
Set driver = driver.switchToWindow(beforeHwd) 'Switches focus to the specified window. | |
driver.get "/tatsuya" | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Call driver.get("/tatsuya/java/winopen.htm") << This line produce the following error
13 UnknownError
unknown error: net::ERR_NAME_NOT_RESOLVED
(Session info: chrome=108.0.5359.125)
(Driver info: chromedriver=108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016}),platform=Windows NT 10.0.19045 x86_64)
beforeHwd = driver.WindowHandle << This line produce this error
438 Object doesn't support this property or method