Run IE as a different user in UFT script
Question ID: 105580
0
0

I need the ability to test IE using different users. With manual testing, I can use Shift + right-click on IE’s icon and select Run As Different User and change the user that way. How can I do this with UFT?

Marked as spam
Posted by (Questions: 89, Answers: 4)
Asked on September 5, 2014 7:55 pm
520 views
Answers (1)
1
Private answer

Try the following code. Of course, you'll want to change the variable values to match your testing needs. Also, if you don't want to use the local computer for the domain, you'll need to change that too. If not, it retrieves the computer name for the domain automatically:

set objShell= Wscript.CreateObject(''WScript.Shell'')

Set objNetwork = WScript.CreateObject(''WScript.Network'')
''Variable Values assignment

domain = objNetwork.ComputerName
program = ''iexplore.exe''
domainUser = ''Testuser1''
password = ''passwordvalue''

objShell.Run ''runas /env /user:'' & domain & '''' & domainUser & '' '' & ''''''C:Program FilesInternet Exploreriexplore.exe''''''

Wscript.Sleep 2000

'Delay before typing password in window. Adjust if needed

objShell.Sendkeys password

Wscript.Sleep 1000
objShell.SendKeys ''{ENTER}''
Wscript.Quit

Marked as spam
Posted by (Questions: 2, Answers: 477)
Answered on September 5, 2014 7:56 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top