Contributions
Re: determining if a local printer exists
Hello, You can use WMI to retrieve information on the connected printers. Then do a string compare or the like to determine if your printer is found. eg. To list printer details: Sub Printers() strComputer = "." strQuery = "Select * From Win32_Printer" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colPrinters = objWMIService.ExecQuery(strQuery) For Each objPrinter in colPrinters strResult = objPrinter.Name If objPrinter.Default Then strResult = strResult & " - (Default)" End If If objPrinter.Local Then strResult = strResult & " - Local Printer" Else strResult = strResult & " - Network Printer" End If Log.Message(strResult) Next End Sub Cheers, Jackson751Views0likes0CommentsRe: ip address of test machine
Hello Stephanie, For the computer name you can use Sys.HostName. However there doesn't look like there's one for the IP address. You can try using WMI to gather the IP address http://msdn.microsoft.com/en-us/library/aa394217(VS.85).aspx eg. Sub LogIPAddress strQuery = "select * from Win32_NetworkAdapterConfiguration where IPEnabled=True" Set colItems = GetObject("winmgmts:").ExecQuery(strQuery) Log.Message sys.HostName For Each objItem In colItems Log.Message(objItem.DNSHostName) Log.Message(objItem.IPAddress(0)) Next End Sub Cheers, Jackson1.3KViews1like0CommentsRe: About text box testing
Hello Uday, I'd use the ObjectSpy to find out what the set limit is for the textbox. http://support.smartbear.com/viewarticle/11926/ Otherwise you could write a loop function to keep appending a single character to the textbox, read the data from the textbox and check the length. Once it's hit the limit the length would remain the same. For questions 2 and 3, I assume if you enter in invalid characters, these will be ignored by the textbox. If that's the case, record yourself entering data, then read the textbox and compare with the expected results. eg. I've used a Windows 7 machine with the Notepad Save As dialog box open for this example. This textbox is alphanumeric but it's just to show you what I expect if this was a numeric only textbox. Sub ForumTextBox() 'Win 7 Notepad Save As dialog box -> file name textbox Set NotepadTextBox = Aliases.NOTEPAD.Window("#32770", "Save As", 1).Window("DUIViewWndClassName", "", 1).Window("DirectUIHWND", "", 1).Window("FloatNotifySink", "", 1).Window("ComboBox", "", 1).Window("Edit", "", 1) 'Textbox limit Log.Message("Textbox limit: " & NotepadTextBox.wLimit) 'Set text as whatever Call NotepadTextBox.keys("123abc4") 'Read the textbox. strText = NotepadTextBox.wText 'Check the content - On a numeric only textbox, the letters would be ignored. If (strText = "1234") Then Log.Message("Passed") Else Log.Error("Failed") End If End Sub Cheers, Jackson1.4KViews0likes0CommentsRe: is there a way to differentiate between text to picture(gif,bmp,jpg,etc)?
Hello Ofer, I'm so use to VBScript/JScript I was coding in that. I see you're probably using C# script or the like. Did some reading and looks like you can use GetVarType() to determine the variant type. http://support.smartbear.com/viewarticle/12102/ eg. function Test() { // Storing and getting an image //Sys["Clipboard"] = Sys["Process"]("notepad")["Window"]("Notepad", "Untitled - Notepad", 0)["Picture"](); // Storing and getting text Sys["Clipboard"] = Sys["Process"]("notepad")["Window"]("Notepad", "Untitled - Notepad", 0)["WndCaption"]; TypeID = GetVarType(Sys["Clipboard"]); Log["Message"]("Type: " + TypeID); if (TypeID == varOleStr) { Log.Message("A string is held in the clipboard"); } else { Log.Message("A picture is held in the clipboard"); } } Cheers, Jackson1KViews0likes0CommentsRe: Import and export functionality in test complete
Hello Reha, TestComplete supports VBScript, JScript, DelphiScript, C++ script and C# script. If your script is written in any of these then yes you can copy from your script. Have a look at the following: http://support.smartbear.com/viewarticle/11274/ Cheers, Jackson2KViews0likes0CommentsRe: Sort VB6 array in Test Complete
Hello Krushna, You mean VBScript? There's no function in vbscript to sort an array. Array.Sort() is available in JScript. Our test machines all have .Net installed so I use the method described in the following: http://stackoverflow.com/questions/268648/how-do-i-sort-arrays-using-vbscript Otherwise you'd have to perform a bubble sort on your array which is also listed on the page above. Cheers, Jackson1.1KViews0likes0CommentsRe: is there a way to differentiate between text to picture(gif,bmp,jpg,etc)?
Hello Ofer, Reading from the documentation http://support.smartbear.com/viewarticle/11044/ When Sys.Clipboard holds an image, the property returns a Picture object. You can use the IsObject() function to see if the clipboard returns an object. eg. If IsObject(Sys.Clipboard) Then Log.Message("A picture is held in the clipboard") Else Log.Message("A string is held in the clipboard") End if Cheers, Jackson1KViews0likes0Comments