开发者

handle security popup using vbscript (without QTP/Selenium)

开发者 https://www.devze.com 2023-04-08 06:42 出处:网络
I am automating an application login using vbscript. I am using the code - Dim objIE Set objIE = Wscript.CreateObject(\"InternetExplorer.Application\")

I am automating an application login using vbscript.

I am using the code -

Dim objIE
Set objIE = Wscript.CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate "https://portal url"

after this, there is a security pop up which asks for user name and password.

I dont want to disable the pop-up. Rather i want to be able to put user id and password in to it.

I tried handling it through

NewWindow3 method and NewWindow2 method

which MSDN has provided for handling extra windows(This for development rather than for automation I guess) but does not work out.

`objIE.Document.GetElementByID

also does not work out becuse the pop-up does not come under 'Document' object. it comes directly under objIE, but could not find anythi开发者_运维技巧ng to handle it.


I use following code for pass credentials to the Windows Authentication dialog. I hope it helps.

Dim objIE, objWshShell
Set objIE = WScript.CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate "http://url"
Set objWshShell = WScript.CreateObject("WScript.Shell")
With objWshShell
    WScript.Sleep 100
    .SendKeys "myusername" 'Focused by Default - Username
    WScript.Sleep 100
    .SendKeys "{TAB}" 'Skip To Password Field
    WScript.Sleep(100)
    .SendKeys "mypassword" 'Password     
    WScript.Sleep 100
    .SendKeys "{TAB}" 'Skip To "Remember Me" Checkbox
    WScript.Sleep 100
    .SendKeys "{TAB}" 'Skip To Submit Button
    WScript.Sleep 100
    .SendKeys "{ENTER}" 'GO
End With
Set objWshShell = Nothing
Set objIE = Nothing
0

精彩评论

暂无评论...
验证码 换一张
取 消