blueprintmrk / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 0 forks source link

Reusing / Sharing one session using Selenium Webdriver with multiple Subroutines #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Operating system : Windows Vista + Firefox 12.0
.Net Framework version : 3.5
Office Version : 2003
SeleniumWrapper version : 1.0.5.1

What steps will reproduce the problem?
1. I am running a test that requires me to log in to my account. I recorded 
this macro, say Sub1, using IDE.
2. After Sub1 is finished I am unable to do any more operations on my account, 
as another Macro, say Sub2, only works if I open a new Selenium Session, log in 
again and run additional code.

What is the expected output? What do you see instead?

I would ideally like to run a Sub 2 from the point where Sub 1 has finished, 
reusing the currectly opened Selenium Webdriver session.

Please provide any additional information below.

Pls could you provide a piece of code with 2 Subs, where the second Sub is able 
to continue from the point where Sub 1 has finished, without the need to open a 
new session (or log in again, as in my case). 

In other words, using a very simple example:

'Sub1 opens a session and loads google.com
Public Sub1()
   Dim selenium As New SeleniumWrapper.WebDriver
   selenium.start "firefox", "http://www.google.com/"
   selenium.open "http://www.google.com"
   selenium.stop
End Sub

'I would like now Sub2 to open yahoo.com page at the same session as one opened 
by previously by Sub1. I made up Continue key word, but this is what I would 
exactly need.

Public Sub2()
   selenium.CONTINUE "firefox", "http://www.google.com/"
   selenium.open "http://www.yahoo.com"
   selenium.stop
End Sub

Original issue reported on code.google.com by steepd...@gmail.com on 5 Jun 2012 at 11:01

GoogleCodeExporter commented 9 years ago
That should do the trick as long as you don't press the reset button :

Dim selenium As SeleniumWrapper.WebDriver

Public Sub StartSelenium()
   Set selenium = New SeleniumWrapper.WebDriver
   selenium.Start "firefox", "http://www.google.com/"
End Sub

Public Sub PlayWithGoogle()
   selenium.Open "http://www.google.com"
   ...
End Sub

Public Sub PlayWithYahoo()
   selenium.Open "http://www.yahoo.com"
   ...
End Sub

Public Sub StopSelenium()
   selenium.stop
   Set selenium = Nothing
End Sub

Original comment by florentbr on 5 Jun 2012 at 11:51

GoogleCodeExporter commented 9 years ago

Original comment by florentbr on 8 Sep 2014 at 5:34