QTP – createObject – read excel sheet

September 14, 2010

Public Sub GetQTPConfig Set xlApp = CreateObject(“Excel.Application“) Set xlBook = xlApp.WorkBooks.Open(“C:\QTP\Config\qtpconfig.xls”) Set xlSheet = xlBook.WorkSheets(“Sheet1″)   ‘Retrieve local config settings    sUserName = xlSheet.Rows(2).Columns(2).Value    sPassword = xlSheet.Rows(3).Columns(2).Value    sScriptPath = xlSheet.Rows(4).Columns(2).Value    sEnv = xlSheet.Rows(5).Columns(2).Value   xlBook.Close xlApp.Quit Set xlSheet = Nothing Set xlBook = Nothing Set xlApp = Nothing End Sub

Read the full article →

C# example to read soap message

May 16, 2010

C# example to read soap message.   Task:  Read the following xml using c# and return the count of how many flights and the price and flight number from each flight element. This is my sample xml: <s:Envelope xmlns:s=”http://schemas.xmlsoap.org/soap/envelope/“>       <s:Body>             <GetFlightsResponse xmlns=”HP.SOAQ.SampleApp”>         […]

Read the full article →

VB Script example to read soap message

May 15, 2010

VB Script example to read soap message… Task: Read the following xml using vbs and return the count of how many flights and the price and flight number from each flight element. This is sample xml: <s:Envelope xmlns:s=”http://schemas.xmlsoap.org/soap/envelope/“>       <s:Body>             <GetFlightsResponse xmlns=”HP.SOAQ.SampleApp”>             […]

Read the full article →

C# – Regular Expressions

September 14, 2009

class TstRegExpr { static void Main() { string[] sentences = { “cow over the moon”, “Betsy the Cow”, “cowering in the corner”, “no match here” }; string sPattern = “cow”; foreach (string s in sentences) { System.Console.Write(“{0,24}”, s); if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { System.Console.WriteLine(” (match for ‘{0}’ found)”, sPattern); } else { System.Console.WriteLine(); } } […]

Read the full article →

C# parse strings using Split method

August 1, 2009

class TestStringSplit { static void Main() { char[] delimiterChars = { ‘ ‘, ‘,’, ‘.’, ‘:’, ‘\t’ }; string text = “one\ttwo three:four,five six seven”; System.Console.WriteLine(“Original text: ‘{0}’”, text); string[] words = text.Split(delimiterChars); System.Console.WriteLine(“{0} words in text:”, words.Length); foreach (string s in words) {        System.Console.WriteLine(s); } } } Output   Original text: ‘one two […]

Read the full article →

C# read ini file

July 9, 2009

using System; using System.Runtime.InteropServices; using System.Text; � public static class IniFile {   [DllImport("kernel32")]   private static extern long WritePrivateProfileString(string section,string key, string val, string filePath);   [DllImport("kernel32")]   private static extern int GetPrivateProfileString(string section,string key, string def, StringBuilder retVal,int size, string filePath); �   public static void WriteValue(string path, string Section, string Key, string […]

Read the full article →

QTP – Invoke Application function

July 9, 2009

Here is a code snippet to start Internet Explorer with a custom function: Public Function StartApplication (MyURL)  Dim TheURL  TheURL=MyURL  Set ObjIE = CreateObject (“InternetExplorer.Application”)  ObjIE.Visible= TRUE  ObjIE.Navigate TheURL  Set ObjIE=Nothing End Function

Read the full article →

Connection Strings

June 9, 2009

http://www.connectionstrings.com/sql-server-2008  

Read the full article →