51Testing软件测试论坛

标题: QuickTest Professional :Random Name Generator [打印本页]

作者: pcl2004_27    时间: 2006-10-30 14:20
标题: QuickTest Professional :Random Name Generator
Description

      How to generate random names at run time?


Solution

      This code will generate how much ever random names you need.

Steps :

#1
Attach the RandomPicker.vbs to your test first.

#2
Add this code to your test :

' ***********************
Dim nCnt

nCnt = Inputbox("Enter the number of Names needed")

RandomPicker(nCnt)

arrName = split(rName,",")

For i = 1 to nCnt - 1

Msgbox arrName(i)

Next

' ***********************


#3
Try running the test.



This code will generate the random names that you give as input in the InputBox.
Note : You can also add some validation to restrict the number of value in InputBox.


vbs code:


Dim  rName, rInt

Public Sub RandomPicker(rCnt)

        rName = "SANJAY"

        For rInt = 1 To rCnt

                ' Picking up seconds of current time                                                                                                                                                                                                                                  
                aVal = time
                arrVal = split(aVal,":")
                aVal = arrVal(2)
                aVal = left(aVal,2)
                 
                ' Picking up date of current date                                                                                                                                                                                                                                  
                bVal = date
                arrVal = split(bVal,"/")
                bVal = arrVal(0)
               
                ' Manuplating it to Generate Random Number
                cVal = aVal + bVal
                dVal = aVal * bVal
                zVal = cVal * dVal
                fVal = left(zVal,2)
                gVal = right(zVal,2)
                fVal = fVal + rInt
                 gVal = gVal + rInt
                                          
                If rInt Mod 2 = 0 Then
                         
                         ' Set of Different combination of words stored in an array
                         One = array("AZK","AJJ","AZD","AZC","AZB","QNW","QNX","AZV","AZU","AZT","AZS","QNN","QNO","QNP","QNQ","AZN","AZM","AZR","AZQ","QNI","QNJ","QNK","KPG","KPH","KPI","KPJ","KPM","KPN","KPO","KPU","KPV","KPW","KPX","KPY","KPZ","OLA","OLB","OLC","OLD","OLX","OLY","OLZ","QNA","QNB","QNC","QND","QNE","QNF","QNG","QNH","AZL","QNY","AZY","AZX","AZW","QNR","QNS","AZH","AZG","AZF","AZE","AZP","AZO","QNL","QNM","KPA","KPT","OLE","OLF","OLG","OLH","OLI","OLJ","OLK","OLL","OLM","OLN","OLO","KPB","KPC","KPD","KPE","KPF","KPP","KPQ","KPR","KPS","AZA","AZZ","QNT","QNU","QNV","OLR","OLS","OLT","OLU","OLV","OLW","KPK","KPL","QNZ","AZI","OLP","OLQ")
                         iVal = One(fVal)
                         
                         Two = array("KPB","KPC","KPD","KPE","KPF","KPP","KPQ","KPR","KPS","AZA","AZZ","QNT","QNU","QNV","OLR","OLS","OLT","OLU","OLV","OLW","KPK","KPL","QNZ","AZI","OLP","OLQ","AZY","AZX","AZW","QNR","QNS","AZH","AZG","AZF","AZE","AZP","AZO","QNL","QNM","KPA","KPT","OLE","OLF","OLG","OLH","OLI","OLJ","OLK","OLL","OLM","OLN","OLO","KPM","KPN","KPO","KPU","KPV","KPW","KPX","KPY","KPZ","OLA","OLB","OLC","OLD","OLX","OLY","OLZ","QNA","QNB","QNC","QND","QNE","QNF","QNG","QNH","AZL","QNY","AZK","AJJ","AZD","AZC","AZB","QNW","QNX","AZV","AZU","AZT","AZS","QNN","QNO","QNP","QNQ","AZN","AZM","AZR","AZQ","QNI","QNJ","QNK","KPG","KPH","KPI","KPJ")
                         jVal = Two(gVal)
                         
                Else
                         
                         Three = array("AZY","AZX","AZW","QNR","QNS","AZH","AZG","AZF","AZE","AZP","AZO","QNL","QNM","KPA","KPT","OLE","OLF","OLG","OLH","OLI","OLJ","OLK","OLL","OLM","OLN","OLO","AZK","AJJ","AZD","AZC","AZB","QNW","QNX","AZV","AZU","AZT","AZS","QNN","QNO","QNP","QNQ","AZN","AZM","AZR","AZQ","QNI","QNJ","QNK","KPG","KPH","KPI","KPJ","KPM","KPN","KPO","KPU","KPV","KPW","KPX","KPY","KPZ","OLA","OLB","OLC","OLD","OLX","OLY","OLZ","QNA","QNB","QNC","QND","QNE","QNF","QNG","QNH","AZL","QNY","KPB","KPC","KPD","KPE","KPF","KPP","KPQ","KPR","KPS","AZA","AZZ","QNT","QNU","QNV","OLR","OLS","OLT","OLU","OLV","OLW","KPK","KPL","QNZ","AZI","OLP","OLQ")
                         iVal = Three(fVal)
                         
                         Four = array("KPM","KPN","KPO","KPU","KPV","KPW","KPX","KPY","KPZ","OLA","OLB","OLC","OLD","OLX","OLY","OLZ","QNA","QNB","QNC","QND","QNE","QNF","QNG","QNH","AZL","QNY","AZY","AZX","AZW","QNR","QNS","AZH","AZG","AZF","AZE","AZP","AZO","QNL","QNM","KPA","KPT","OLE","OLF","OLG","OLH","OLI","OLJ","OLK","OLL","OLM","OLN","OLO","KPB","KPC","KPD","KPE","KPF","KPP","KPQ","KPR","KPS","AZA","AZZ","QNT","QNU","QNV","OLR","OLS","OLT","OLU","OLV","OLW","KPK","KPL","QNZ","AZI","OLP","OLQ","AZK","AJJ","AZD","AZC","AZB","QNW","QNX","AZV","AZU","AZT","AZS","QNN","QNO","QNP","QNQ","AZN","AZM","AZR","AZQ","QNI","QNJ","QNK","KPG","KPH","KPI","KPJ")
                         jVal = Four(gVal)
                         
                End If
                          
                kVal = iVal & jVal
                         
                If rName="SANJAY" Then
                         
                         rName = kVal
                       
                Else
                         
                         rName = rName + "," + kVal
                               
                End If
                         
                         
        Next                         
       
End Sub




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2