Open GoogleCodeExporter opened 8 years ago
[deleted comment]
It's not possible to run some new code against an already opened browser, which
means that avoiding “selenium.Start” is not possible.
So you can either deal with multiple instances of a WebDriver or you can manage
multiple windows.
==An example with multiple instances:==
Dim driver1 As SeleniumWrapper.WebDriver
Dim driver2 As SeleniumWrapper.WebDriver
Public Sub StartBrowsers()
driver1 = New SeleniumWrapper.WebDriver
driver2 = New SeleniumWrapper.WebDriver
driver1.Start "firefox", "http://uk.news.yahoo.com"
driver2.Start "firefox", "http://uk.news.yahoo.com"
driver1.Open "opinion"
driver2.Open "business"
End Sub
Public Sub StopBrowsers()
driver1.stop
driver2.stop
End Sub
Public Sub DoSomethingOnCondition()
SeleniumWrapper.WebDriver driver
Select Case InputBox("Select the instance's number or nothing to exit", "")
Case "1": driver = driver1
Case "2": driver = driver2
End Select
'you script here
'driver. ...
End Sub
==An example with multiple windows:==
Dim driver As SeleniumWrapper.WebDriver
Dim window1 As String
Dim window2 As String
Public Sub StartBrowser()
driver = New SeleniumWrapper.WebDriver
driver.Start "firefox", "http://uk.news.yahoo.com"
'Saves the first window
window1 = driver.WindowHandle
driver.Open "opinion"
'Gets a second window
driver.executeScript "window.open();"
hwnds = driver.WindowHandles
driver.switchToWindow hwnds(1)
window2 = driver.WindowHandle
driver.Open "business"
End Sub
Public Sub StopBrowser()
driver.stop
End Sub
Public Sub DoSomethingOnCondition()
Select Case InputBox("Select the window's number or nothing to exit", "")
Case "1": driver.switchToWindow window1
Case "2": driver.switchToWindow window2
End Select
'you script here
'driver. ...
End Sub
Original comment by florentbr
on 27 Jan 2014 at 12:41
As you well described what I need is to run a new code against an already
opened browser. I will continue trying a solution. I hope it exists. Thank you
very much for your attention.
Original comment by lpo5...@gmail.com
on 27 Jan 2014 at 1:07
Original comment by florentbr
on 8 Sep 2014 at 5:40
Original issue reported on code.google.com by
lpo5...@gmail.com
on 26 Jan 2014 at 1:29