Tuesday, November 27, 2018

Test Complete- Search data in csv or text file

public function searchdatainfilr()
strfilepath="c:\test. csv
set objfso=createobject(" scripting. filesystemobject")
set infile=objfso. opentextfile("strfilepath")
set outpath=objfso. opentextfile(strfilepath & ". tmp", 2,true)
dim irowcnt
irowcnt=0

do while not infile. atendofstream
line=inline. readline
fullfile=fullfile & line
loop

log. message fullfile
if instr(fullfile, "searctxtval") >0  then
     log. message "validation pass"
else
    log. message "validation fail"
end if
infile. close
outfile. close
objfso. deletefile(strfilepath l
objfso. movefile strfilepath & ". tmp", strfilepath

end function

Tuesday, November 20, 2018

Test Complete- Move file from source to destination

function fnMovefile(Sourcepath, destinationpath)
'path given till folder level only
' code to find csv file from particular location
set foundfiles=aqfilesystem. findfiles(sourcepath, "*.csv")
if not foundfiles is nothing then
    while foundfiles. hasnext
        set afile=foundfiles. next
        var_foundfiles=afile. name
    wend
else
     log. message "no files were found"
end if
call aqfilesystem. copyfile(soyrcepath, deatinationpath)
nowtime=aqdatetime. time()
nowtime=aqstring(nowtime, ":", "_")
nowtime=aqstring(nowtime, "pm", "_")
nowtoday=aqdatetime. today()
nowtoday=aqconvert. vartostr(nowtoday)
nowtoday=aqstring.replace(nowtoday,"/","_")
destinationfile=destinationpath & "\" & varfoundfiles
destinationfilerename=destinationpath & "\" & nowtine & "_" & nowtoday & "_" & varfoundfiles
call aqfile. rename(destinationfike, desti ationfilerename)
log. message " move file with rename successfully"
end function

Test Complete - Find value is present in excel sheet or not

function searchdatainexcel(strpath, searchcol, searchval)
path="c:abc. xls"
set searchdata=DDT. exceldriver(strpath, "sheet1", true)
do while not searchdata. EOF
   if aqconvert. vartostr(searchdata. value(searchcol)) =searchvalue then
       blnflag=true
       exit do
   else
       blnflag =false
   end if
searchdata. next
loop
if blnflag =true then
    log. message "record match"
else
   log. message "record not match"
end if
end function

Monday, October 8, 2018

Tosca intergration with c#

Hey folks,
Tosca is one of tge tool used for automation, however personally i dont feel much great tool.
You could write your own advanced logic in C# and integrate it with Tosca. I found this link after almost 1.5 months efforts.
Though it's challenging but helpful to get help after many tickets on tosca support
.
Integration of C# with Special Execution task
  1. First we need to create a new XModule in our TOSCA Commander:
  2. On this new Module switch to the Properties tab and create two additional configuration parameters and name them "SpecialExecutionTask" and "Engine".
  3. The Engine parameter specifies which assemblies/engines are searched for theSpecialExecutionTask specified in the second parameter. We are going to tag our assembly with “TutorialEngine” in order to tell TOSCA to search in our assembly. The key for ourSpecialExecutionTask is "Hello World"
Preparing Visual Studio
First create a new Class Library in C# and make sure you have selected the .Net Framework 4.0. There are 2 assemblies we need to reference in order to successfully create our SET:
·     Tricentis.Automation.Creation
·     Tricentis.Automation.Interaction
These can be found in “%TRICENTIS_HOME%\Automation\Framework\”.
Right click on References in your Solution Explorer and choose Add Reference: Answer the following warning that might pop up by clicking "Yes". Change the "Copy Local" property of the References to "false".
Next we are going to tag our AssemblyInfo (can be found in your project, under Properties->AssemblyInfo.cs) with the necessary information, we already defined in our Module:
We are going to use the namespace
using Tricentis.Automation.Creation.Attributes;
and add the following EngineIdAttribute:
[assembly: EngineId("TutorialEngine")]
 Now we are going to implement our SpecialExecutionTask. We need a class "HelloWorld.cs". You can either create a new class or rename the automatically created "Class1.cs". Then add an attribute to this class. This links the XModule to our class. Add
usingTricentis.Automation.Engines.SpecialExecutionTasks.Attributes;
to any existing usings, as well as the attribute SpecialExecutionTaskName
[SpecialExecutionTaskName("HelloWorld")]
public class HelloWorld {
}
to our class. 
Our class is going to derive from the abstract class SpecialExecutionTask. We are going to override the Execute method. In this method we return a passing resultwith our message.
public class HelloWorld : SpecialExecutionTask {
    public override ActionResultExecute(ISpecialExecutionTaskTestAction testAction) {
        return newTricentis.Automation.Engines.PassedActionResult("Hello World!");
    }
}
Now build the assembly for AnyCPU and copy the output *.dll to %TRICENTIS_HOME%\Automation\Framework\
You should now be able to use the XModule in a TestCaseand see the results in your ExecutionList:

cheers
Trupti