danwagnerco / selenium-vba

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

how to send user credentials through VBA selenium #136

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Operating system :Win7
.Net Framework version :4.5
Office Version :2010
SeleniumWrapper version :1.0.23.0

What is your issue ?
i want to send username and password for intranet site which accepts 
authentication through popup. I have tried to pass credentials through selenium 
webdriver components but I could not find anything useful, I figured out a way 
through VBA sendkeys and it works in IE, but does not work consistently in 
firefox and chrome.

selenium.Start browser, "http://www.google.com"
selenium.setSpeed (2000)

selenium.Open "http://xyz.abc.com"
If (browser = "ie") Then
    AppActivate ("Windows Security")
    SendKeys "username", True
    SendKeys "{TAB}", True
    SendKeys "password", True
    SendKeys "{ENTER}", True
Else
    AppActivate ("Authentication Required")
    SendKeys "username", True
    SendKeys "{TAB}", True
    SendKeys "password", True
    SendKeys "{ENTER}", True
End If

Any input is highly appreciated. 

Original issue reported on code.google.com by santhosh...@gmail.com on 6 Feb 2015 at 11:39

GoogleCodeExporter commented 9 years ago
The best way it to send the credentials within the Url 
(http://user:password@example.com):

Dim wd As New SeleniumWrapper.WebDriver
wd.start "firefox", "http://test:test@browserspy.dk/password-ok.php"
wd.open "/"

It works by default with Firefox and Chrome, but it requires a registry tweak 
for IE.
Add the DWORD value name="iexplore.exe" data=0 in this key:

32-bit windows:
HKLM\Software\Microsoft\Internet 
Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE

64-bit windows:
HKLM\Software\Wow6432Node\Microsoft\Internet 
Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE

Original comment by florentbr on 7 Feb 2015 at 10:08

GoogleCodeExporter commented 9 years ago
I have already tried by passing credentials in 
URL(http://username:password@sitename) and it did not work. I thought the 
reason might be the way we provide user name. The format of username in my case 
is domain\userName or userName@abc.com

Original comment by santhosh...@gmail.com on 9 Feb 2015 at 5:05

GoogleCodeExporter commented 9 years ago
Have your tried the domain in the Url with the backslash encoded (%5C)?
http://domain%5Cuser:password@example.com

Original comment by florentbr on 9 Feb 2015 at 6:38

GoogleCodeExporter commented 9 years ago
I have tried it now, but it is not working. I can see the authentication pop up 
while executing the script and user credentials are not filled automatically. 
After 3000 ms, timeout error is displayed

Original comment by santhosh...@gmail.com on 9 Feb 2015 at 7:17