09-14-2012, 04:38 PM
hi Guys im new to qtp, i have attached the coding below
The Problem start when Function RegexSelectQTP is false the next iteration starts from this line of code Browser(Dbrowser6).Page(Dpage6).Link(Dlink4).Click, where as it should have started from the beginning of the script and incremented the row count as well, im guessing its something to do with the two functions that i have used here and the way i have used the term next, would really appreciate any help to sort this out...
The Problem start when Function RegexSelectQTP is false the next iteration starts from this line of code Browser(Dbrowser6).Page(Dpage6).Link(Dlink4).Click, where as it should have started from the beginning of the script and incremented the row count as well, im guessing its something to do with the two functions that i have used here and the way i have used the term next, would really appreciate any help to sort this out...
Code:
Dim xlApp, xlBook, xlSheet
Dim iRow, CINNUMBER, PrpsedCode, CurrentCode
CONST iUserNameCol = 1
CONST iUserNameCol2 = 2
CONST iUserNameCol3 = 3
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.WorkBooks.Open("C:\Users\99016790\Desktop\RM Markers.XLSX")
Set xlSheet = xlBook.WorkSheets("RM")
For iRow = 2 to xlSheet.UsedRange.Rows.Count
CINNUMBER = xlSheet.Rows(iRow).Columns(iUserNameCol).Value
PrpsedCode = xlSheet.Rows(iRow).Columns(iUserNameCol2).Value
CurrentCode = xlSheet.Rows(iRow).Columns(iUserNameCol3).Value
Set Dwindow=description.Create
Dwindow("micclass").value="Window"
Dwindow("windowstyle").value="382664704"
Set Dbrowser=description.Create
Dbrowser("micclass").value="Browser"
Dbrowser("openurl").value="about:blank"
Set Dbrowser1=description.Create
Dbrowser1("micclass").value="Browser"
Dbrowser1("name").value="Relationship management"
Set Dpage=description.Create
Dpage("micclass").value="page"
Dpage("name").value="BAPEU"
Set Dpage1=description.Create
Dpage1("micclass").value="page"
Dpage1("title").value="Relationship management"
Set Dlink=description.Create
Dlink("micclass").value="Link"
Dlink("html id").value="menuItem_37"
Set Dlink2=description.Create
Dlink2("micclass").value="Link"
Dlink2("html id").value="menuItem_82"
Set Dlink3=description.Create
Dlink3("micclass").value="Link"
Dlink3("name").value="Continue"
Set Dwebedit=description.Create
Dwebedit("micclass").value="WebEdit"
Dwebedit("html id").value="klcKeyLocateSearchPage.klcProductNo"
Window(Dwindow).Activate
Browser(Dbrowser).Page(Dpage).Link(Dlink).Click
Browser(Dbrowser).Page(Dpage).Link(Dlink2).Click
Browser(Dbrowser1).Page(Dpage1).WebEdit(Dwebedit).Set CINNUMBER
Browser(Dbrowser1).Page(Dpage1).Link(Dlink3).Click
Set Dbrowser6=description.Create
Dbrowser6("micclass").value="Browser"
Dbrowser6("width").value="644"
Set Dpage6=description.Create
Dpage6("micclass").value="Page"
Dpage6("width").value="644"
Set DwebList6=description.Create
DwebList6("micclass").value="WebList"
DwebList6("html id").value="sSelectedPortFolioDetails"
Browser(Dbrowser6).sync
typ1 = CurrentCode & ".*"
RegisterUserFunc "WebList", "RegexSelectQTP", "RegexSelectQTP"
Browser(Dbrowser6).Page(Dpage6).WebList(DwebList6).RegexSelectQTP (typ1)
Set Dlink4=description.Create
Dlink4("micclass").value="Link"
Dlink4("name").value="Change manager"
Set Dwebedit1=description.Create
Dwebedit1("micclass").value="WebEdit"
Dwebedit1("name").value="PSL001DisplayKC.PortfolioId"
Browser(Dbrowser6).Page(Dpage6).Link(Dlink4).Click
Browser(Dbrowser6).Sync
Browser(Dbrowser6).Page(Dpage6).WebEdit(Dwebedit1).Set PrpsedCode
wait(01)
Var = Window("foreGround:=True").GetROProperty("hwnd")
Set Dwindow1=description.Create
Dwindow1("micclass").value=("Window")
Dwindow1("hwnd").value=Var
Window(Dwindow1).Close
Window(Dwindow).Activate
next
Function RegexSelectQTP(Object, sPattern)
Dim oRegExp, arrAllItems, ix
Set oRegExp = New RegExp
oRegExp.IgnoreCase = False
oRegExp.Pattern = sPattern
arrAllItems = Split(Object.GetROProperty("all items"), ";")
For ix = LBound(arrAllItems) To UBound(arrAllItems)
If oRegExp.Test(arrAllItems(ix)) Then
Object.Select "#" & & ix
Set oRegExp = Nothing
Exit Function
End If
Next
Var = Window("foreGround:=True").GetROProperty("hwnd")
Set Dwindow1=description.Create
Dwindow1("micclass").value=("Window")
Dwindow1("hwnd").value=Var
Window(Dwindow1).Activate
wait 0,100
Set Keyboard = DotNetFactory.CreateInstance( "Microsoft.VisualBasic.Devices.Keyboard", "Microsoft.VisualBasic" )
Call Keyboard.SendKeys( "^a", True )
Call Keyboard.SendKeys( "^c", True )
Set Dwindow2=description.Create
Dwindow2("micclass").value=("Window")
Dwindow2("text").value="Closed Account - Notepad"
Window(Dwindow2).Activate
Call Keyboard.SendKeys( "^v", True )
wait (1)
Call Keyboard.SendKeys( "~", True )
Call Keyboard.SendKeys( "~", True )
Window(Dwindow1).Activate
Window(Dwindow1).Close
Window(Dwindow).Activate
End Function
Set xlSheet = Nothing
Set xlSheet = Nothing
Set xlApp = Nothing