sagarpabba / selenium-vba

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

Proxy Settings #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Operating system : Win7
.Net Framework version : 2.0.7045
Office Version : 2003
SeleniumWrapper version : 1.0.11.0

Please could you provide sample VBA code, how to configure proxy settings for 
Selenium Session?

For example:
I have proxy address together with a port number (yy), say:
xxx.xxx.xxx.xxx:yy

I would like Selenium to connect to the internet via this proxy.

To check that everything is configured correctly I would then use selenium to 
go to any IP lookup site and see that my IP is indeed xxx.xxx.xxx.xxx

Original issue reported on code.google.com by steepd...@gmail.com on 1 May 2013 at 8:44

GoogleCodeExporter commented 9 years ago
You can use the setProxy command :
 selenium.setProxy "xxx.xxx.xxx.xxx"
 selenium.start "firefox", "http://www.google.com"
 selenium.open "/"

Or you can manually create a new Firefox profile with the desired proxy and use 
it :
 selenium.setProfile "Selenium"
 selenium.start "firefox", "http://www.google.com"
 selenium.open "/"

Original comment by florentbr on 4 May 2013 at 7:40

GoogleCodeExporter commented 9 years ago
Many thanks for this reply. selenium.setProfile works exactly as I wanted.

Is there however a way to have 2 Selenium Sessions, one with proxy the other 
without running on the same Excel Instance, and be able to use both of them at 
the same time?

I have prepared a code below, but it returns the following error:

Run-time error '-2146233088 (80131500)'

Unable to bind to locking port 7054 within 45000 ms

Dim selenium As SeleniumWrapper.WebDriver
Dim selenium2 As SeleniumWrapper.WebDriver

'Session with proxy

Public Sub StartSelenium()
   Set selenium = New SeleniumWrapper.WebDriver
   selenium.setProfile "Selenium"
   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

'Session without proxy

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

Public Sub PlayWithGoogle2()
   selenium2.Open "http://www.google.com"

End Sub

Public Sub PlayWithYahoo2()
   selenium2.Open "http://www.yahoo.com"

End Sub

The same error repeats, even when I use a separate Excel Instance.

Original comment by steepd...@gmail.com on 5 May 2013 at 5:38

GoogleCodeExporter commented 9 years ago
Can you tell me which line is throwing the error?

Original comment by florentbr on 6 May 2013 at 1:04

GoogleCodeExporter commented 9 years ago
Thank for looking into this. I checked on my PC and on Windows Azure W2008 
instance:

on my PC:
as i run sub after sub, it stops at line:
selenium2.Start "firefox", "http://www.google.com/"

and I get:
Run-time error '-2146233088 (80131500)'
Unable to bind to locking port 7054 within 45000 ms

I believe second instance of Selenium Webdriver Browser doesn't want to load 
here

On Windows Azure I am able to launch second instance of Selenium Webdriver 
Browser, but am not able to go back and forth between 2 instances for example 
After running Subs in the following order:

StartSelenium
PlayWithGoogle
PlayWithYahoo

StartSelenium2
PlayWithGoogle2

PlayWithGoogle - nothing will happen here.

PlayWithYahoo2 - but this one will work

Is it actually possible to use two Selenium Webdriver Browsers parallely? as I 
tried in the above sequence? IE. once I open second Selenium Webdriver Browser, 
can i still go back to the first Browser, and run macros on that instance?

If so could you please provide sample VBA code that will work?

Original comment by steepd...@gmail.com on 6 May 2013 at 11:47

GoogleCodeExporter commented 9 years ago
I had a look at the code and found that it's not currently possible to work 
with two instances at the same time due to some temporary file cleaning at each 
instanciation.
It will be fixed in the next release.

Original comment by florentbr on 8 May 2013 at 1:16

GoogleCodeExporter commented 9 years ago
Fixed in version 1.0.13.3

Original comment by florentbr on 7 Jun 2013 at 1:10