1

When click on sharepoint link, it alerts below authentication for username & password

enter image description here

Is there any way to handle this authentication ?

sam m
  • 74
  • 1
  • 14
  • What do you mean by "handle"? – thatthing Oct 02 '15 at 09:57
  • I don't want to type username & password manually on each attempt. Is there any code to ignore this manual typing ? – sam m Oct 02 '15 at 10:44
  • 1
    Take a look at this, should give you what you need http://stackoverflow.com/questions/16023869/how-to-automate-username-password-fill-for-firefox-authentication-popup-using-se – Jsmith2800 Oct 02 '15 at 11:00
  • Yes but on this link _Fiddle Freak_ found the solution by using **AutoIT**. What is the solution in **Selenium VBA** or how to convert below code into Selenium VBA ? `WinWaitActive("Authentication Required") Send("Username") Send("{TAB}") Send("Password") Send("{ENTER}")` – sam m Oct 02 '15 at 11:57
  • any suggustion ? which pertinent to the subject matter. – sam m Oct 07 '15 at 10:27

1 Answers1

1

With the credentials in the URL (Basic Authentication only):

Dim driver As New IEDriver
driver.Get "http://admin:admin@the-internet.herokuapp.com/basic_auth"

With the SetCredential method (not implemented with all the drivers):

Dim driver As New IEDriver
driver.Get "http://the-internet.herokuapp.com/basic_auth"

Dim dlg As Alert: Set dlg = driver.SwitchToAlert(Raise:=False)
If Not dlg Is Nothing Then
  dlg.SetCredentials "admin", "admin"
  dlg.Accept
End If

With WScript (only works locally):

Dim driver As New IEDriver
driver.Get "http://the-internet.herokuapp.com/basic_auth"

Dim dlg As Alert: Set dlg = driver.SwitchToAlert(Raise:=False)
If Not dlg Is Nothing Then
  Set wsh = CreateObject("WScript.Shell")
  wsh.SendKeys "admin"
  wsh.SendKeys "{TAB}"
  wsh.SendKeys "admin"
  dlg.Accept
End If

With AutoIt (only works locally):

Dim driver As New IEDriver
driver.Get "http://the-internet.herokuapp.com/basic_auth"

Dim dlg As Alert: Set dlg = driver.SwitchToAlert(Raise:=False)
If Not dlg Is Nothing Then
  Set aut = CreateObject("AutoItX3.Control")
  aut.Send "admin"
  aut.Send "{TAB}"
  aut.Send "admin"
  dlg.Accept
End If

To get the latest version in date working with the above examples: https://github.com/florentbr/SeleniumBasic/releases/latest

Florent B.
  • 41,537
  • 7
  • 86
  • 101
  • _Thanks for your support [florentbr](http://stackoverflow.com/users/2887618/florentbr) :) and I just want to confirm, is there any way to use below codes on **Firefox** driver? `Dim driver As New IEDriver` `driver.Get "http://the-internet.herokuapp.com/basic_auth"` `Dim dlg As Alert: Set dlg = driver.SwitchToAlert(Raise:=False)` `If Not dlg Is Nothing Then` `dlg.SetCredentials "admin", "admin"` `dlg.Accept` `End If' – sam m Jan 15 '16 at 06:34
  • 1
    Sure: Dim driver As New FirefoxDriver – Florent B. Jan 22 '16 at 06:45
  • Not Working :( **( I think it cannot be implemented with all the driver)** – sam m Feb 04 '16 at 06:03