The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:




Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Testing Tools >> Micro Focus/Borland/Segue SilkTest

Pages: 1 | 2 | 3 | (show all)
kotiatsqaforums
Member


Reged: 06/22/08
Posts: 67
Loc: Hyderabad, AndhraPradesh
Re: Donate a user defined function to this topic [Re: chinna_you]
      #493659 - 06/23/08 05:30 AM

This function is to search for a string the Source code of a web page.

Parameters:
Page -> Window
SearchStr -> String to search for

Return value: TRUE (if exists) or FALSE (if not exists)

Code:

[+] Boolean SearchString(Window Page, String SearchStr)
[ ] Page.SetActive()
[ ] lsFile=Page.GetPageSource(FALSE)
[-] for i=1 to ListCount(lsFile)
[-] if (StrPos(SearchStr,lsFile[i])!=0)
[ ] //Print(lsFile[i])
[ ] goto Done
[ ] Done:
[ ] bFound = MatchStr("*{SearchStr}*", lsFile[i])
[ ] //print(bFound)
[ ] return bFound



Edited by jamesso (11/19/08 07:27 AM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
rakeshraghvani12345
Junior Member


Reged: 01/21/05
Posts: 336
Loc: UK
Re: Donate a user defined function to this topic [Re: kotiatsqaforums]
      #524515 - 10/15/08 07:02 AM

To BlockInput function blocks keyboard and mouse input events
Code:

[-] dll "user32.dll"
[ ] int BlockInput(int fBlockIt)
[-] testcase TestInput() appstate none
[ ] BlockInput(1)
[ ] Sleep(10)
[ ] BlockInput(0)


Press CTRL+ALT+DEL to recover, if your function fails to unblock input!

Edited by jamesso (11/19/08 07:28 AM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
Rajanish_Thakur
Member


Reged: 03/06/08
Posts: 125
Loc: Bangalore,India
Re: Donate a user defined function to this topic [Re: chinna_you]
      #533444 - 11/21/08 03:49 AM

////////////////////////////////////Functions for removing double space between strings////////////////////


[+] STRING RemoveExtraSpace_Double(STRING sOriginal1, STRING sReplacement)
[ ] string sOriginal = AddSpace(sOriginal1)
[ ] STRING sResult = ""
[ ] STRING sTemp
[ ] INTEGER iCounter
[ ] int i =0
[-] for iCounter = 1 to Len(sOriginal)
[ ] ////Print("sOriginal[{iCounter}]",sOriginal[iCounter])
[ ] sTemp = sOriginal[iCounter]
[-] if((Asc(sTemp) != 32) )
[ ] i=0
[-] if ( (Asc(sTemp) == 32))
[-] if(i==0) || (i==1)
[ ] sResult = sResult + sTemp
[-] if(i !=0 ) && (i !=1 )
[ ] sResult = sResult + sReplacement
[ ] i = i+1
[ ]
[-] else
[ ] sResult = sResult + sTemp
[ ] return sResult



[+] string AddSpace(string Orig)
[ ] int i
[ ] string sChang=Orig
[ ] //Print(Orig)
[+] // for(i=1;i<=len(Orig);i++)
[ ] // sChang =""
[-] for(i=1;i<=len(Orig);i++)
[-] if(isdigit(Orig))
[-] if(isspace(Orig[i+1]))
[ ] sChang = Stuff (Orig,i+1,0," ")
[ ] Orig=sChang
[-] if(isalpha(Orig))
[ ]
[ ] //Print("Final Change",sChang)
[ ] return sChang

--------------------
Thanks & Regards,
RS_Thakur


Post Extras: Print Post   Remind Me!   Notify Moderator  
Rajanish_Thakur
Member


Reged: 03/06/08
Posts: 125
Loc: Bangalore,India
Re: Donate a user defined function to this topic [Re: Rajanish_Thakur]
      #533447 - 11/21/08 03:55 AM


///Fuctions for searching a string in text file//

[+] boolean grepfind38( string sFile,STRING sMatchItem,out string output)
[ ] HFILE OutputFileHandle
[ ] STRING sLine
[ ] FILESHARE fShare
[ ] fShare = FS_DENY_NONE
[ ] OutputFileHandle = FileOpen(sFile,FM_READ,fShare)
[-] while (FileReadLine (OutputFileHandle, sLine))
[-] if (MatchStr("*"+sMatchItem+"*",sLine))
[ ] output =sLine
[ ] return (true)
[-] else
[ ] output =" "
[ ] FileClose(OutputFileHandle)
[ ] return(false)

--------------------
Thanks & Regards,
RS_Thakur


Post Extras: Print Post   Remind Me!   Notify Moderator  
davidgenrich
Moderator


Reged: 06/30/99
Posts: 539
Loc: Fremont, CA, USA
Re: Donate a user defined function to this topic [Re: Rajanish_Thakur]
      #539536 - 12/18/08 01:07 PM

Why go through all the trouble of the RemoveExtraSpace_Double () function to remove double spaces when you can simply use the 4Test function StrTran ():

Code:

// replace double space with a single space
string myString = "This is a Test"


myString = StrTran (myString, " ", " ")




--------------------
David Genrich
david.genrich@e2open.com


Post Extras: Print Post   Remind Me!   Notify Moderator  
TesterDec06
Newbie


Reged: 12/31/08
Posts: 21
Re: Donate a user defined function to this topic [Re: Bapanna Setti]
      #546484 - 01/28/09 11:21 PM

Hi blacst,

Thanks for your function BOOLEAN SetBrowserEnvironment().I have a query in the function. In the function, you are using a variable called "HKEY_LOCAL_MACHINE". Can you please guide me where it is initalized. Because i am getting an error like "the variable is not defined"

Thanks in advance


Post Extras: Print Post   Remind Me!   Notify Moderator  
Ravindra_QA
Member


Reged: 09/18/08
Posts: 29
Loc: Bengaluru, Karnataka
Re: Donate a user defined function to this topic [Re: TesterDec06]
      #549718 - 02/11/09 07:17 AM

Here is a function that we can use to calculate page load times.
[-] Void timercode()
[ ] //Timer starts here
[ ] STRING sOverallTime
[ ] HTIMER TotalTimer
[ ] TotalTimer = TimerCreate ()
[ ] TimerStart (TotalTimer)
[ ] Browser.WaitForReady ()
[ ] TimerStop (TotalTimer) //stopping the timer
[ ] sOverallTime = TimerStr (TotalTimer)
[ ] Print ("The Page loads in {sOverallTime} seconds")
[ ] TimerDestroy (TotalTimer)

--------------------
------------
Ravindra

"If you have the inclination, you have the time"


Post Extras: Print Post   Remind Me!   Notify Moderator  
cyb_abhijeet
Member


Reged: 11/05/08
Posts: 88
Re: Donate a user defined function to this topic [Re: chinna_you]
      #578680 - 07/08/09 04:29 AM

This simple code will compare the string line by line within the File by using MatchStr()

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

HFILE hfile = SYS_FileOpen ("\\machine1\SharedFiles\ApplicationLog.log")
STRING sLine

While (FileReadLine(hFile, sLine))
if(MatchStr("*fatal errors*", sLine))
Print("String Matched")
else
Print ("No Match Found")
FileClose(hFile)


Post Extras: Print Post   Remind Me!   Notify Moderator  
RakeshSharma
Member


Reged: 04/14/07
Posts: 73
Loc: Gurgaon, India
Re: Donate a user defined function to this topic [Re: chinna_you]
      #590398 - 09/10/09 09:53 PM

// Fuction to pick the date from Date control in VB form.

[+] POINT LocateCalander(WINDOW wDate)
[ ] POINT p
[ ] INTEGER iMaxYPosition
[ ] INTEGER iXIncrement = 20, iYIncrement = 30
[ ] INTEGER iXStartPos = 15, iYStartPos = 15
[-] with WinForm.Date1
[ ] iMaxYPosition = .GetRect().yPos-.GetRect().ySize
[ ] RECT rect
[ ] rect = wDate.GetRect()
[ ] p.x = iXStartPos
[ ] p.y = iYStartPos
[-] while(!Calander.Exists())
[+] if p.x >= rect.xPos
[ ] p.x = iXStartPos
[ ] p.y = p.y+iYIncrement
[ ] continue
[+] if p.y > iMaxYPosition
[ ] break
[ ] wDate.Click(1, p.x, p.y)
[ ] p.x = p.x+iXIncrement
[ ] return p

--------------------
Regds,
Rakesh
If fate means you to lose, give it a good fight anyhow


Post Extras: Print Post   Remind Me!   Notify Moderator  
AmitX
Member


Reged: 09/16/08
Posts: 43
Re: Donate a user defined function to this topic [Re: chinna_you]
      #619686 - 03/25/10 10:52 PM

Picking value from registry and available throughout the whole testcase

[ ]
[ ] use "msw32.inc"
[ ]
[ ] int sKey=HKEY_LOCAL_MACHINE
[ ] String sKeyPath="SOFTWARE\Employee\"
[ ]
[ ] const eName="eName"
[ ] const eAge="eAge"
[ ] const eDept="eDept"
[ ] const eEcn="eEcn"
[ ] const eAdd="eAddress"
[ ] const eWait="waittime"
[ ]
[ ] //record of employee
[+] type Employee is record
[ ] int eEcn
[ ] String eName
[ ] int eAge
[ ] String eAddress
[ ] String eDept
[ ] int wait
[ ]
[ ] Employee emp
[ ]
[ ] //function which is picking value from registry
[+] void GetUserOption(inout Employee emp)
[ ] print("Entering in GetUserOption function ")
[+] do
[ ] emp.eName=Sys_GetRegistryValue(sKey,sKeyPath,eName)
[-] except
[ ] ExceptLog()
[-] do
[ ] emp.eAge=Val(Sys_GetRegistryValue(sKey,sKeyPath,eAge))
[+] except
[ ] ExceptLog()
[+] do
[ ] emp.eDept=Sys_GetRegistryValue(sKey,sKeyPath,eDept)
[+] except
[ ] ExceptLog()
[+] do
[ ] emp.eEcn=Val(Sys_GetRegistryValue(sKey,sKeyPath,eEcn))
[+] except
[ ] ExceptLog()
[+] do
[ ] emp.eAddress=Sys_GetRegistryValue(sKey,sKeyPath,eAdd)
[+] except
[ ] ExceptLog()
[-] do
[ ] emp.wait=Val(Sys_GetRegistryValue(sKey,sKeyPath,eWait))
[+] except
[ ] ExceptLog()
[ ]
[ ] //override default recovery system
[+] ScriptEnter()
[ ] GetUserOption(emp)
[ ]
[ ]
[ ] //testcase: which read value from registry
[+] testcase ReadFromRegistry() appstate none
[ ] print("Employee Name:->" +emp.eName)
[ ] print("Employee Age:->" +Str(emp.eAge))
[ ] print("Employee Address:->"+emp.eAddress)
[ ] print("Employee code:->" +Str(emp.eEcn))
[ ] print("Employee Dept:->"+emp.eDept)
[ ] print("Wait Time:->"+Str(emp.wait))
[ ]

--------------------
Amit Nigam

SQA,Oracle


Post Extras: Print Post   Remind Me!   Notify Moderator  
beniamin
Member


Reged: 11/27/08
Posts: 27
Re: Donate a user defined function to this topic [Re: AmitX]
      #619726 - 03/26/10 04:39 AM

Hi,

I have been working on the issue to have all result related files automatically uploaded to SCTM when executing a SilkTest test case.
The problem was that SCTM execution server (respectively the ST runtime) generetes for each test case an own result folder. So when you try to do for example screen shots, logs or anything related to the specific test case the files won't be uploaded automatically to SCTM.

here comes the solution from Borland:

Code:
 [-] STRING CalculateResultDirPath()
[ ] STRING dirPath = "{SYS_GETENV("TMP")}\SCC_ExecServer_19124_19125\PerfProjects"
[-] if (SYS_DirExists(dirPath))
[ ] LIST OF FILEINFO fileInfos
[ ] datetime lastModified = "1970-01-01 00:00"
[ ] INTEGER newestResultDirIdx = 1
[ ] fileInfos = SYS_GetDirContents(dirPath)
[ ]
[ ] FILEINFO fileInfo
[ ] INTEGER i = 1
[-] for each fileInfo in fileInfos
[-] if (fileInfo.bIsDir && lastModified < fileInfo.dtLastModifyTime)
[ ] lastModified = fileInfo.dtLastModifyTime
[ ] newestResultDirIdx = i
[ ] i++
[ ] return "{dirPath}\{fileInfos[newestResultDirIdx].sName}"
[-] else
[ ] dirPath = "{SYS_GETENV("TEMP")}\Bitmap"
[-] if !SYS_DirExists(dirPath)
[ ] SYS_MakeDir(dirPath)
[ ] return dirPath



Have fun...


Post Extras: Print Post   Remind Me!   Notify Moderator  
LangtonBen
Newbie


Reged: 03/31/09
Posts: 7
Re: Donate a user defined function to this topic [Re: chinna_you]
      #628556 - 05/28/10 11:44 AM

Here's a function that finds a window/control within a window, recursively. I use it with a data-driven framework, so that I can operate on controls nested within containers, without having to specify the full path like window.container1.container2.control.

[ ] // Returns a variable of type WINDOW for sControl within wWindow
[ ] // sControl may be an indirect descendant of the window (ex. grandchild)
[ ] // Helper function for a number of other functions
[-] WINDOW GetChildWindow(WINDOW wWindow, STRING sControl)
[-] // 2010-04-21 - Ben Langton
[ ] // Example:
[ ] // dlgDialog
[ ] // DataWin dwDataWin
[ ] // DWEditField txtField
[ ]
[ ] // GetChildWindow(dlgDialog, txtField)
[ ] // Returns the WINDOW dlgDialog.DWEditField.txtField
[ ]
[ ] // Debug code
[ ] // Print("GetChildWindow({wWindow}, {sControl})")
[ ]
[ ] // Reference to the control that will eventually be returned
[ ] WINDOW wControl
[ ]
[ ] // If sControl has a "." in it, try to resolve the reference - only one level deep, currently
[ ] // Generally, it's safest not to call this function with sControl having a "." in it.
[ ] // Because this may be a bit sketchy...
[-] if(StrPos(".", sControl) > 0)
[ ] wWindow = GetChildWindow(wWindow, GetField(sControl, ".", 1))
[ ] sControl = SubStr(sControl, StrPos(".", sControl) + 1)
[ ] wWindow = GetChildWindow(wWindow, sControl)
[ ]
[ ] // If the control has been found, then return it.
[-] if(wWindow.sName == sControl)
[ ] return wWindow
[ ]
[ ] // Loop through the children of the window until the specified control is found
[ ] WINDOW wWinChild
[-] for each wWinChild in wWindow.lwChildren
[ ] // Debug Code
[ ] // Print("Child: {wWindow}.{wWinChild.sName}")
[ ]
[-] if(wWinChild.sName == sControl)
[ ] // Debug Code
[ ] Print("GetChildWindow found child '{sControl}' in '{wWinChild}'")
[ ]
[ ] return wWinChild
[ ]
[ ] // Only get here if the specified control is not a child of the window (ex. it could be a grandchild)
[ ] // Call the function recursively, passing in the child.
[ ] wControl = GetChildWindow(wWinChild, sControl)
[-] if(IsNull(wControl) == False)
[ ] return wControl
[ ]
[ ] return NULL


Post Extras: Print Post   Remind Me!   Notify Moderator  
bellis89
Newbie


Reged: 06/23/11
Posts: 7
Re: Donate a user defined function to this topic [Re: chinna_you]
      #704121 - 04/12/12 01:48 PM

I had to write IDs of items created to a file and recall them.


Write to file

[-] HFILE ProjectID
[ ] // Open file, append variable and close file
[ ] ProjectID = FileOpen ("<insert path and name of file>", FM_WRITE)
[ ] FileWriteLine (ProjectID, "{sProjectID}")
[ ] FileClose (ProjectID)


To read from file

[-] string GetProjectID()
[ ] HFILE ProjectIDRead
[ ] STRING sProjectID
[ ] ProjectIDRead = FileOpen ("<insert path and name of file>", FM_READ)
[ ] while (FileReadLine (ProjectIDRead, sProjectID))
[ ] FileClose (ProjectIDRead)
[ ] return sProjectID


Locator looks like this

[-] DomElement ProjectID
[ ] locator "//A[@id='{GetProjectID()}']/../../..//IMG"


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1 | 2 | 3 | (show all)



Extra information
0 registered and 12 anonymous users are browsing this forum.

Moderator:  AJ, jamesso, DJGray, David Reed 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating: ****
Topic views: 52667

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5