Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with using two functions in the same action
#1
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...
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 "#" &amp & 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
Reply
#2
Use ExitActionIteration to exit the iteration and start with the second iteration.
Reply
#3
thanks ankesh i tried what you said and i included the ExitActionIteration statement the way i have mentioned below, but now when the second function is false the script just stop, what i want it do is continue with the next CINNUMBER from the excel list... hope you can help with this
Code:
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 ExitActionIteration
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Action Parameter passing problem Qtpuser1 1 3,272 04-18-2014, 06:23 AM
Last Post: kgovadav
  Perform some functions whenever QTP Stop button is pressed smartkarthi 2 3,798 08-22-2013, 11:43 AM
Last Post: smartkarthi
  exit parent functions as well Shridevi.Salagare 3 4,519 07-31-2013, 12:15 AM
Last Post: Ankur
  Datatable in functions shwetasharma 2 4,078 03-26-2013, 08:00 AM
Last Post: sams001
  Can you do functions by calling filename or any other better ways? chong67 2 3,769 05-29-2012, 11:41 PM
Last Post: chong67

Forum Jump:


Users browsing this thread: 1 Guest(s)