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

Friday, October 5, 2018

Read XML file as string using Vbscript

hi folks, To read XML file as entirely string we can use below logic. Hope it will useful.

set xmldoc=createobject("MICROSOFT. XMLDOM")
xmldoc. async=false
xmldoc. load(recentxmlfilepath)
for each ochdnd in xmldoc. documentelement. childnodes
     strxmldocline=ochdnd. nodename & ":" & ochdnd. text & vbcrlf
xmldocdata= xmldocdata & strxmldocline
next
msgbox xmldocdata

cheers
Trupti