Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Password Encryption while entering during run time.
#1
Not Solved
'=============================================
'Action Name : To Login
'=============================================

Code:
'Initiaze the String variables
Dim InpUserName, InpPass, PassString

' To Enter  Network ID while running
InpUserName = InputBox ("Enter Username", "User Input")
Browser("micclass:=Browser").Page("micClass:Page").WebEdit("userid").Set InpUserName

'To enter Network ID Password
InpPass = InputBox ("Enter Password")
PassString = Crypt.Encrypt(InpPass)
Browser("micclass:=Browser").Page("micClass:Page").WebEdit("pwd").SetSecure PassString
Browser("micclass:=Browser").Page("micClass:Page").WebButton("Sign In").Click

--------------------------------------------------------------

Question: As we change the n/w password quiet frequently, I have used this method to login while running the script. But Even after trying lot of times I couldnt find a way to encrypt the password while runnig the script, Like Gmail password with asteriks (****). Anyone Please advise.
Reply
#2
Not Solved
Which part are you desiring for the asteriks to come up ?
1. On the Password InputBox?
2. On the application?
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#3
Not Solved
The best way I know how is to use .NET components. These functions can be added to a function library or just included in the test you are running.

Code:
Public Function EncryptedPassword()
    Dim dialogForm, dialogTextBox, dialogAcceptButton, dialogStartPosition, dialogBorderStyle, ResultEnum
    
    Set dialogForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
    Set dialogTextBox = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
    Set dialogAcceptButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
    Set dialogStartPosition = DotNetFactory.CreateInstance("System.Windows.Forms.FormStartPosition", "System.Windows.Forms")
    Set dialogBorderStyle = DotNetFactory.CreateInstance("System.Windows.Forms.FormBorderStyle", "System.Windows.Forms")
    Set ResultEnum = DotNetFactory.CreateInstance("System.Windows.Forms.DialogResult", "System.Windows.Forms")
    
    dialogForm.Text = "Enter Password"  
    dialogForm.Width = 250
    dialogForm.Height = 100
    dialogForm.MinimizeBox = False
    dialogForm.MaximizeBox = False
    dialogForm.StartPosition = dialogStartPosition.CenterScreen
    dialogForm.FormBorderStyle = dialogBorderStyle.FixedDialog
    
    dialogTextBox.UseSystemPasswordChar = True
    dialogTextBox.Width = 220
    dialogTextBox.Top = 15
    dialogTextBox.Left = 15
    
    dialogAcceptButton.Text = "OK"
    dialogAcceptButton.Top = 45
    dialogAcceptButton.Left = 90
    
    dialogForm.AcceptButton = dialogAcceptButton
    dialogForm.AcceptButton.DialogResult = ResultEnum.OK
    dialogForm.Controls.Add dialogTextBox
    dialogForm.Controls.Add dialogAcceptButton
    
    Do
        dialogForm.ShowDialog(GetQtpNativeWindow)
        dialogForm.Text = "Enter Password - CANNOT BE BLANK"  
    Loop While dialogTextBox.Text = ""
        
    EncryptedPassword = Crypt.Encrypt(dialogTextBox.Text)
    'MsgBox dialogTextBox.Text
    
    dialogAcceptButton.Dispose
    dialogTextBox.Dispose
    dialogForm.Dispose
    
    Set dialogBorderStyle = Nothing
    Set dialogStartPosition = Nothing
    
    Set dialogAcceptButton = Nothing
    Set dialogTextBox = Nothing
    Set dialogForm = Nothing
End Function
        
Private Function GetQtpNativeWindow
    Dim hWnd, qtpWnd
    Set hWnd = DotNetFactory.CreateInstance("System.IntPtr", "Mscorlib", Window("RegExpWndTitle:=QuickTest Professional.*").GetROProperty("hWnd"))
    Set qtpWnd = DotNetFactory.CreateInstance("System.Windows.Forms.NativeWindow", "System.Windows.Forms")
    qtpWnd.AssignHandle hWnd
    Set GetQtpNativeWindow = qtpWnd
    Set hWnd = Nothing
    Set qtpWnd = Nothing
End Function

Then to use it with your code, you simply call the EncryptedPassword function for your SetSecure call. It will prompt with a password masked box.

Code:
Browser("micclass:=Browser").Page("micClass:Page").WebEdit("pwd").SetSecure EncryptedPassword

EDIT: I should point out that those functions really shouldn't be included in the test itself, they will run MUCH faster if included in a function library.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to create List box in excel sheet at Run time with values yes No JACKSPARROW 0 1,685 01-17-2017, 11:05 AM
Last Post: JACKSPARROW
  HI, i'm having a run time error ,please help? Awzar 0 2,592 01-24-2015, 06:52 AM
Last Post: Awzar
  Loading objects in qtp at run time nitin 0 2,394 12-03-2013, 09:11 PM
Last Post: nitin
  Run time error RPS_QTP 1 2,445 10-04-2012, 01:57 PM
Last Post: krr
  Run time Data table to QC sshukla12 1 3,639 04-02-2012, 02:45 PM
Last Post: sshukla12

Forum Jump:


Users browsing this thread: 1 Guest(s)