Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Sunday, June 10, 2018

Protractor - Getting browser log

Sometimes we need to get browser console information to validate tests. Protractor has ablity to retrieve the console info.

Need to add LoggingPrefs into config file and then you can access browser console info as per below code.

config:
'browserName': 'chrome', name: 'chrome-scripts', count: 1, loggingPrefs: { "driver": "INFO", "browser": "INFO" }



Code:
browser.manage().logs().get('browser').then(function(browserLog) { console.log('No of info from console:' + browserLog.length); browserLog.forEach(function(logInfo){ console.log('browser console info: ' + require('util').inspect(logInfo)); consoleInfo = require('util').inspect(logInfo); if (consoleInfo.indexOf('name:') !== -1) { expect(consoleInfo).toContain(fileToUpload); } else if (consoleInfo.indexOf('size:') !== -1) { expect(consoleInfo).toContain(fileSizeInBytes); } }); });



Sunday, October 22, 2017

CDrive free space was going down

My HDD free space is usually 30 GB. On weekends in last month, I noticed that machine performance was too slow. Then I checked HDD free space, which is less than 10GB. Used system cleanup for C Drive and got another 500 MB space.

Did few google search and found utility - TreeSize to get to know the utilized space by each directory.

Lastly found that Office cache had more than 30 GB for Office 2015 and Office 2016 versions. Removed all cache from following directories and Machine performance is so much better.
**Office Cache - C:\Users\\AppData\Local\Microsoft\Office\16.0\OfficeFileCache1
**Office Cache - C:\Users\\AppData\Local\Microsoft\Office\15.0\OfficeFileCache
**Office Cache - C:\Users\\AppData\Microsoft\Office\15.0\OfficeFileCache

Wednesday, February 4, 2015

Copy all comments from MS Word document

I tried today only and it worked. Go to your first comment and select all the text. Press SHIFT key and DOWN arrow key simultaneously up-to reaching the last comment. Then Copy (CTRL+C) and Paste (CTRL+V) in any text editor. All the comments would be available. Saving Time..

Sunday, December 1, 2013

Code Coverage in Testing

Primarily code coverage is used for unit testing and many test teams are practicising code coverage for test execution. Visual Studio team have been doing many improvements on code coverage area. Code coverage is available for Unit tests in prior version. In Visual Studio 2012 Update 3, Code coverage can be measured for manual and automated tests. Also there are few integrations with MTM (Microsoft Test Manager) tool.

Advantages of Code Coverage on Testing
  • Increase the confidence level on Quality
  • Measure the code coverage through tests
  • Help to improve testing to cover un-touched code
  • Additional test cases to increase code coverage


Limitations of Code Coverage on Testing
  • Unable to find incomplete or dead code
  • Not a proof whether code is written against specifications

You need to add your application DLLs into codecoverage.config file which is available at "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Dynamic Code Coverage Tools". Then use following commands in Administrator mode to get the coverage data. After stopping the code coverage, you can open the coverage results file in Visual Studio and expand the DLLs to method level.

Useful Commands
 
Path==> C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Dynamic Code Coverage Tools Command to run codecoverage tool ==> CodeCoverage.exe collect /IIS /session:WebSession /output:MyApp_20131009.coverage Command to stop codecoverage tool ==> CodeCoverage.exe shutdown /session:WebSession
Different attributes and options are available in code coverage tool. YOu can check your environment. CodeCoverage Help command
 
Usage: CodeCoverage Available Commands: Collect coverage data to the given coverage file. Usage: collect [options] [command line] Options: /config: [optional] Override default configuration with configuration file specified. /IIS [optional] Collect code coverage for web applications running under Internet Information Service (IIS). IIS Worker process (w3wp.exe) will be registered for collection and all the application pools will be restarted. /output: [required] The file to output coverage data to. /session: [optional] The name for the session. If a session name is not provided, a unique session name will be used /verbose [optional] Turn on printing of diagnostic information during runtime. Example: CodeCoverage collect /IIS /session:WebSession /output:MyWebApp.coverage Shut down a logger with a given session name. Usage: shutdown [options] Options: /session: [required] The name of the session to shut down Example: CodeCoverage shutdown /session:WebSession Analyze data from one or more coverage files and output XML. Usage: analyze [options] [file2 [...]] Options: /include_skipped_functions [optional] Includes skipped functions in the results. /include_skipped_modules [optional] Includes skipped modules in the results /output: [optional] The file to output the analyzed coverage data to The default is to use standard output /test: [optional] The test identifier string to limit the coverage data to. This option can be specified multiple times to merge coverage data for different tests together Example: CodeCoverage analyze /include_skipped_functions /include_skipped_modules /output:results.xml MyWebApp.coverage

Monday, September 10, 2012

Windows Startup error code 0x00000074:BAD_SYSTEM_CONFIG_INFO

Two weeks back, My laptop was unable to start. I got blue screen and error message as BAD_SYSTEM_CONFIG_INFO and error code as 0x00000074

I thought it might be due to Hard disk crash or some other internal issues. But actually these issues were due to some software updates either Windows or Anti-Virus. I used System Restore option to correct this issue. Microsoft has given few more options to recover on Windows 7. You can go through the following links.

What are the system recovery options in Windows 7?
Choosing an advanced recovery method
Startup Repair: frequently asked questions


Hope it may help to few others too!!!

Sunday, February 12, 2012

RobotFramework Standards

RobotFramework team has given guidelines --> HowToWriteGoodTestCasesWithExamples. Similar to coding standards, Automation team should use certain guidelines for Keyword-Driven framework also. It would be more useful to functional team as well as other teams.

Test Suite / Script

  • Test Script names should be less than 20 characters and file type should be HTML.
  • It should be easily readable and self-explanatory.
  • Remember that suite names are created automatically from file/directory names. Extensions are stripped, underscores are converted to spaces and, if name is all lower case, words are capitalized. For example login_tests.html -> Login Tests and DHCP_and_DNS -> DHCP and DNS.
  • Documentation should be updated with purpose of the script and pre-conditions.
  • Proper keywords should be given for Suite Setup, Suite Teardown, Test Setup and Test Teardown.
  • Should not have too many tests (max 50) in one suite unless they are data-driven.

TestCases / Tests
  • Test case names should be less than 40 characters and file type should be HTML.
  • Test case Name should be in camel case (In a word, First letter is capital and remaining letters are in small).
  • It should be easily readable and self explanatory.
  • Documentation should be updated with manual test case steps, notes and pre-conditions.
  • Proper keywords should be given for Suite Setup, Suite Teardown, Test Setup and Test Teardown.
  • Appropriate tags should be given for each case.
  • Tests should be independent.
  • In dependant tests, detailed notes should be given. Consider verifying the status of the previous test using ${PREV TEST STATUS} variable.
  • Hard coding of object name should be avoided.
  • Should contain many high level keywords instead of repeating steps often.
  • High level keywords should be used for navigation.
  • Local variables should have prefix char ‘t’ as temporary variables

Resources
  • Keep all resource files in single folder.
  • Resource file names should be less than 20 characters and file type should be HTML.
  • All characters should be small characters.
  • Documentation should be updated with purpose.
  • All constants should be maintained in separate resource file.
  • Keep separate resource files for application’s data.
  • Keep separate resource files for all GUI objects page wise or module-wise.
  • Group the high level keywords by categories like business logic, module and general.

High Level Keyword / User Keyword / Function
  • Function names should be less than 35 characters.
  • It should be easily readable and self explanatory.
  • For easy readability, it should be in camel case (Capital & Small letters).
  • Prefixes are sometimes useful. For example, Is - to ask a question about something, Get - get a value, Set - set a value
  • Can have space for better readability.
  • Documentation should have clear details for purpose, variables and returning values.
  • Hard coding of object name should be avoided.
  • Arguments should have char ‘p’ as prefix and returned variable should have char ‘r’ as prefix.
  • Local variables should have prefix char ‘t’ as temporary variables
  • Duplicate Functions should not be added.
  • Can contain some programming logic (for loops, if/else)
  • Complex logic in libraries rather than in user keywords
  • Important variables can have comments on the RHS

Variables
  • Variable names should be less than 20 characters.
  • Variables should have meaningful words
  • For easy readability, it should be in camel case (Capital & Small letters).
  • Local variables should have prefix char ‘t’ as temporary variables
  • Arguments should have char ‘p’ as prefix and returned variable should have char ‘r’ as prefix.
  • GUI object variables should have char ‘o’ as prefix.
  • Constant variables should be in Capital letters. For example, APP_URL, DB_SERVER. All other type of variables should have mixed style (small and capital) characters.
  • Script/Global variables should be defined at the top of the script.
  • Function / test case level variables should be defined at top of the function.
  • Can have space. But try to restrict for minimum

Monday, January 30, 2012

Performance Testing Guidance from Microsoft

I always admire Microsoft for its documentation. Right from OS to Office applications, you can find good documentation. Microsoft has shared very good articles for performance testing and tuning.

You can find more articles related to Performance testing available from
Patterns & Practices: Performance Testing Guidance
. Just listed only How-TOs part. Thanks to Microsoft!!!

Performance Testing


Capacity

Load Testing

Stress Testing

Test Cases/Scripting

Troubleshooting

Tuning

Workload Modeling

Hope all these links would be useful..

Sunday, January 29, 2012

JVM Monitoring

Couple of our applications are using Tomcat server. JMeter was used as load testing tool. To monitor Java memory, I used two options. One is JMX(Java Management Extensions) console and Psi-Probe.

To implement those options, you should add following entries into catalina.sh

set CATALINA_OPTS=-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=9005 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false

To access JMX console,Enter command ==> [java_installation]\bin\jconsole hostname:port
To use Probe, you need to deploy in tomcat server instance and then access the probe application.

Saturday, November 26, 2011

JMeter - JDBC Driver issue

I was trying JDBC query execution through JMeter. I was getting the error like java.sql.SQLException: No suitable driver found . I have given ojdbc6.jar on classpath and installed Oracle client. Still JMeter has thrown error. The solution is, ojdbc6.jar should be copied under JMeter Lib folder (<JMeter installation directory>\lib).

Later, the same script was copied into a server and executed the script. Got the same error. Server does not have Oracle client installation and ojdbc6.jar in JMeter lib folder. Just copied the ojdbc6.jar and able to run the script successfully.
Note:
ojdbc6.jar should be used for Oracle 11 version. Also it is supported only Java1.5 and above.

Sunday, October 2, 2011

FOR loops & IF condition in RobotFramework

Using Robot Framework, test engineer can create FOR loops and IF conditions. I don't think so, any other Keyword driven framework is giving this kind of flexibility.

FOR loop can be set in two ways. First one is based on number of items in a List. Another one is based on range like from 1 to 50. Similarly keywords can be executed if condition matches or not. See below example.

FOR Loop & IF condition explantation using Robot Framework

TestCase Action Arguments
VerifyListItems [Arguments] ${Locator} @{ListItems}
[Documentation] Verifies the list of items present in a List Object.
: FOR ${Element} IN @{ListItems}
Select From List ${Locator} ${Element}
List Selection Should Be ${Locator} ${Element}
: FOR ${index} IN RANGE 50
${obj1}= Evaluate ${index}*4+3
Run Keyword if '@{tDriverData}[4]'=='2' Go To MyProfile
Run Keyword Unless '@{tDriverData}[4]'=='2' Go To UserCreation

Monday, February 28, 2011

TaskManager - Tiny Footprint mode

Sometimes back, My laptop did not show menu bar and tabs in Task Manager. I restarted the laptop twice and no success. I searched Microsoft knowledge base and got to know about an interesting thing.

Microsoft KB - Task Manager Menu Bar and Tabs Are Not Visible in Windows XP

Problem
This behavior may occur if Task Manager is running in Tiny Footprint mode.

Resolution
To switch Task Manager to its typical display mode, double-click the top border of the window or the empty space in the border.

Monday, May 31, 2010

Keystroke automation through VBScript

I was looking for a solution, which should do collapse all for silktest code. It is needed before do code comparison. I tried simple VBScript and it is working fine. It is fully based on keystrokes. Below I've shared the code.

VBScript - Sending Keystrokes

' To Collapse All opened Silktest files ' Usage: wscript silktest_collapse.vbs 100 Dim WshShell, iItem, iCount If WScript.Arguments.Count > 0 Then iCount = CInt(WScript.Arguments.Item(0)) Else iCount = 10 End If Wscript.Echo "Count " & CStr(iCount) Set WshShell = Wscript.CreateObject("Wscript.Shell") 'WshShell.AppActivate "Silktest - *" WshShell.SendKeys "%{TAB}" Wscript.Sleep 5000 For iItem=1 to iCount 'To Collapse -> Alt+L+L WshShell.SendKeys "%" WshShell.SendKeys "l" Wscript.Sleep 200 WshShell.SendKeys "l" Wscript.Sleep 1000 'To Save -> Ctrl+S WshShell.SendKeys "^s" Wscript.Sleep 900 'To Close -> Alt+F+C WshShell.SendKeys "%" WshShell.SendKeys "f" Wscript.Sleep 200 WshShell.SendKeys "c" Wscript.Sleep 700 Next Wscript.Echo "Completed."

Tuesday, April 27, 2010

Rules for Object Recognition

Object Recognition is very important thing in any GUI testing tool. Silktest also having set of formats and limitations to identify the objects.

MicroFocus/Borland used to publish "Rules for Object Recognition" document for each silktest release. It is available at techpubs-Rules for Object Recognition

Rules for Object Recognition
Caption - Restricted to 127 characters
WindowID - Restricted to 63 characters
Closest Static Text or Attached Text
4Test Produces – Window Declaration Identifier, Single Tag or Multitag
Agent Produces – Index, Prior Text, Location
Extension Produces – WindowID, Caption

We can manage the automation suite properly for minor application changes by making proper tags. I have given few tips to control the UI changes in the application.
Window declarations Level
1. Object caption change. Use multiple tags
2. Object level change. Assume that UserName text field is under a HtmlTable. Now you set a window variable to have same object level.
3. Same set of objects are in multiple pages. Create a class.
4. Use Variables for page title changes.

Functions Level
1. Navigations. For example, clicking a link, clicking a button.
2. Micro functions. Split to small functions as you have to change in only one place.
3. Use some wrapper functions for all classes. For example, an object is a htmlcheckbox and now it is changed to radio button.

Saturday, January 2, 2010

Strange Internet connection Problem

Recently I saw a strange problem in a laptop, which has Vista OS. I have broadband connection. Router was showing as internet connection successful. But none of the web pages were not loaded. I checked all the internet connection settings. All are correct. I checked in Safari, Internet Explorer and Firefox.

I tried with a startup mode SafeMode with Networking . To know more about these startup modes, see my post Strange behavior with Service Pack. In SafeMode with Networking, I was able to do internet browsing. Then I realized the problem might be due to setting changes or some configuration would have changed.

Solution

  1. Open a command prompt (cmd.exe) with 'Run as administrator' privilege
  2. Type Ipconfig /flushdns and press ENTER key
  3. Type Netsh int ip reset and press ENTER key
  4. Reboot (Re-start) the system
  5. Again Open a command prompt (cmd.exe) with 'Run as administrator' privilege
  6. Type Netsh winsock reset and press ENTER key
  7. Reboot (Re-start) the system again.

After doing above things, I were able to do net surfing. I hope that, Vista is removing the settings or resetting the configuration, if any of devices or drivers went wrong. Microsoft Knowledge-base article has different solution. That solution is You receive an error message in Internet Explorer: "Internet Explorer cannot display the webpage" .

Removing Malware
Elphantboycomputers has prepared wonderful article to Remove Malware. See the section Recap of what you will need to have on-hand before you start the cleanup process

1. To repair or reset Winsock in Vista/Win7
a. Start>Run>cmd [enter]
b. netsh winsock reset catalog [enter]
c. Reboot the system.
2. Sysclean or Multi-AV
3. Full-featured antivirus with updates downloaded separately for manual update
4. MBAM
5. SuperAntiSpyware
6. HijackThis
7. Possibly Process Explorer and Killbox.

Saturday, September 19, 2009

PDF File Verification

Sometimes testers need to verify the PDF file contents. Few times I have seen the questions related to this in few forums. Verifying graphical contents are not so easy. But we can verify the text content in three ways.

First way - Scripting
You can use any other scripting to verify PDF. You can use Java Script or VB Script. In this way, PDF file will not be opened physically and retrieve the contents internally. For more info, Read through this link - Accessing PDF

Second way - Utility
Convert the PDF files to text by using any utility and then verify text files. There are many freewares available for this kind of purpose. I suggest TextMining Tool. In this way also, PDF file is not opened physically.

Sample code in Silktest

 
STRING sPDF2TxtUtil = "F:\TextMining\minetext.exe"
sCmdExecute = "{sPDF2TxtUtil} {sPdfFile} {sConvertedFile}"
Print ("Command: {sCmdExecute}")
SYS_Execute (sCmdExecute,lsCmdOut)
Print (lsCmdOut)

Third way - Using Adobe Reader
In this way, Open the pdf file using Adobe Reader. Then go to File Menu and then click sub menu Save As Text. Now you can store pdf contents as text file and you can use the text file for verification.

To compare the PDF files, you can use comparison softwares (for ex Beyond Compare from 3.0). They internally convert to text file and then comparing it.

Saturday, August 8, 2009

Programmers and Testers

I used to hear the rivalry between developers and testers from my friends. It is common in IT community. The depth of rivalry depends upon the maturity of both testers and developers. Every tester would have experienced this.

Many programmers are experts and specialized in particular technologies. Their duty involves mostly with complicated things. It might be new technology, new tool or new domain. They are not ready to do routine tasks as testing their code fully for each change. Many developers assumes that testing is an easy job and low end work. Sometime it might go as testing team is the wastage of resources, time and money.

Even if any rivalry occurs, it should be bust quickly. Either developer or tester should not take it personal. At the end, both are working for same goal. I hope, now these assumptions would have come down. Now a days, testers are involving automation framework design, unit testing etc.

Following tophics are listed under Interacting with Programmers in Book: Lessons Learned in Software Testing by Cem Kaner, James back and Bret Pettichord

  1. Understanding how programmers think
  2. Develop programmer's trust
  3. Provide Service
  4. Your integrity and competence will demand respect
  5. Focus on the work, not the person
  6. Programmers like to talk about their work. Ask them questions
  7. Programmers like to help with testability

Two weeks back, I was reading Debasis Pradham (Software Testing Zone) blog. Couple of his posts also talking about this feud and how to deal with them.

In Stickyminds.com, I found an article related to this tophic - Across the Great Divide: The Language of Common Ground between Testers and Developers By Susan Joslyn

Sunday, July 19, 2009

Verifying Email notifications

For long time, I was looking a solution to automate the verification of email contents. It required to verify for few user accounts, attachments like Excel, PowerPoint and PDF docs. We have few critical features, which required to verify email contents and attachments. Silktest does not have any built-in functions for this activity. However I have to find a solution. The solution should supports IE6 and IE7 browsers and Windows 2000, Windows XP and Vista OS. I had four choices in mind. They are,

  1. Using a command line utility
  2. Using MS Office Outlook COM interface
  3. Using Collaboration Data Objects (CDO) Interface with Outlook Express
  4. Worst case - Automate any email client with UI

Automate any email client with UI
This option was last one. Because I do not want to automate with User Interface. We can build the solution in couple of weeks effort. The issue is the changes with that client. I have to look on support for different Operating Systems such as Windows XP and Vista.

Using Collaboration Data Objects (CDO) with Outlook Express
In my first company, I have used CDO with Visual Basic. See my previous post - Checking Mail Notification. I got a surprise, while I was searching information for CDO Help. Microsoft has stopped the updates on Outlook Express. Earlier Internet Explorer Intallation was bundled with Outlook Express.

Using MS Office Outlook COM interface
I am familiar with VB script. I have used Outlook COM interface [CreateObject("Outlook.Application")] earlier. The issue is, the particular user account mailboxes should be opened, while executing VB Script. Also I thought the license and installation costs.

Using a command line utility
I have searched many times and found a utility. GetMail is a command line utility and it is working in all windows OS. It is available at GETMAIL for Windows It is a cheapest and best utility to fit for my requirements.

Different Cmdline switches of GetMail
Getmail has different switches for various purposes. You can opt appropriate switches as per your requirement.
 

GetMail v1.33: WinNT console utility to download a mailbox's mail.
syntax:
Getmail -u <user> -pw <password> -s <server> [optional switches (see below)]
Getmail -install [ see install details below ]
Getmail -profile [-delete | "<default>"] [profile1] [profileN] [-q]
Getmail -h [-q]
Getmail -forceextract filename

-install <server> <userid> <password> [<delete> [<xtract> [<try> [<port> [<profile>]]]]]
: set's POP3 server, login, password, whether to delete or not (Yes/No),
whether to automatically extract base64/7bit/UU encoded files or not (Yes/No),
number of tries and port for profile
(<delete> <xtract> <try> and <port> may be replaced by '-').

-u <userid> : Specify userid on remote pop3 host
-pw <password>: Specify password for userid on remote mail host
-s <server> : Specify mail server (pop3) to contact
-nodelete : Do not delete messages after downloading (default)
-delete : Delete messages after downloading
-noxtract : Do not extract base64/7bit/UU files after downloading (default)
-xtract [defname]: Extract base64/7bit/UU encoded files after downloading messages
defname is an optional default filename for the extracted file
-domainstamp : Prepend sender's domain name to extracted attachments
-headersonly : Download only the headers of the message
-port <port> : port to be used on the server, defaults to POP3 (110)
-p <profile> : send with SMTP server, user and port defined in <profile>.
-q : supresses *all* output.
-n <n> : Only get 'n' messages
-m <n> : Only get message # n
-b <n> : Retrieve messages beginning from # n
-plain : Extract text/plain segments too (usually ignored)
-h : displays this help.
-try <n times>: how many attempts to access mail. from '1' to 'INFINITE'
-ti <n> : Set timeout to 'n' seconds.
-forceextract fn: Attempt to extract any encoded messages in 'fn'

Installing GetMail
You need to follow the belows steps to install it. Assume that getmail.exe is stored under D:\tools.
  1. First open a command prompt.
  2. Go to D:\tools folder.
  3. Install it by executing below commmand
    Getmail -install mailserver script1@auto.com wrongpwd
    Here mailserver means the mail Server name or IP address

Verifying GetMail
To verify the GetMail installation, you can use following steps.
  1. Goto folder D:\tools
  2. Execute the following command for any user.
    For example, D:\tools\getmail.exe -u script1 -pw TestPassword -s mailserver
  3. Check any error exists on command prompt.
  4. Check on that folder, whether all the mails are downloaded or not. You can see mails like msg1.txt,msg2.txt,..etc

4Test code - To Verify the GetMail
 

[ ] sMailCommand = "{gsToolsDir}\getmail.exe -u {sUser} -pw {sPass} -s {sServer} {sAdditionalSwitch}"
[ ] Print ("Mail Command: {sMailCommand}")
[+] // if (bDeleteAfterReceive)
[ ] // sMailCommand = "{gsToolsDir}getmail.exe -u {sUser} -pw {sPass} -s {sServer} -delete"
[+] // else
[ ] // sMailCommand = "{gsToolsDir}getmail.exe -u {sUser} -pw {sPass} -s {sServer} -nodelete"
[ ] // Checking any errors on command line output
[+] if( 0 != SYS_Execute( sMailCommand, lsGetmailOut ) )
[ ] ListPrint( lsGetmailOut )
[ ] LogError ( "FAIL. Unable to receive the mail." )
[ ] return FALSE
[ ]

Saturday, December 13, 2008

Close the AUT after certain time

In recent days, I am trying to kill the applications if they are unable to close by the tool (SilkTest). Last month, I was solving one different issue.

We are having ten years old test suite and it was not updated for last two years due to product priorities. The total execution time for this regression suite is around 70 hours. Many times, our AUT is getting hung or the current window focus is unable to shift and suite is unable to continue after that. We endup to stop the suite at that script and re-ran the remaining scripts manually. Also we are unable to use weekends fully for the regression.

I planned to run the scripts as unattended. It is intermittent problem. Often silktest not executed in different testcases and not in one particular case always. So I thought to kill the application if the application is running more than 45 minutes. Few of silktest group members have given a idea and I have implemented it.

Silktest has 'spawn' statement to create a separate thread and it is used to execute MultiTestcase. MultiTestcae helps to run the particular code in multiple systems. Also I used PsList to get the running time of an application. I have tried few scenarios with Notepad and then finally put into our suite. This solution is worked..!!!

I have called in script level and I called 'spawn' statement in ScriptEnter and break the loop, once the execution reached ScriptExit. I have given the code below...

4Test code for ScriptEnter and ScriptExit



[+] void ScriptEnter ()
[ ] // Added for Unattended execution
[ ] gbAppKill = TRUE
[+] spawn
[ ] KillApp_UsedTime ("myAut",2700)
[ ]
[+] void ScriptExit (boolean bException)
[ ]
[ ] // Added to stop kill thread
[ ] gbAppKill = FALSE
[ ]



4Test methods to find the exeuction time and killing it


[ ] // // **** Code written for killing apps if app is running more than 45 mins.
[ ] // Methods
[ ] Boolean gbAppKill
[ ]
[+] Void KillApp_psKill (STRING sApp)
[ ] List of STRING lsOutput
[ ]
[ ] STRING sCommand = "{gcsToolsPath}\pskill {sApp} "
[ ]
[+] do
[ ]
[ ] Print ("Executing command: {sCommand}")
[ ] SYS_Execute (sCommand, lsOutput)
[ ] ResPrintList ("Command Output", lsOutput)
[ ] Print ("echo App {sApp} killed at %DATE%_%TIME% >> d:\kill.txt ")
[ ] SYS_Execute ("echo App {sApp} killed at %DATE%_%TIME% >> d:\kill.txt ")
[ ] Sleep (2)
[+] except
[ ] // Do Nothing
[ ] ExceptLog ()
[ ]
[ ]
[-] VOID KillApp_UsedTime (STRING sApp, INTEGER iKillTimeLimit optional)
[ ] List of STRING lsOutput
[ ] INTEGER iItem, iTotalValue, iTimes, iCount,iSleepTime
[ ] STRING sPartial,sItem,sPID
[ ] STRING sTime, sHour, sMin, sSec
[ ] STRING sCommand = "{gcsToolsPath}\pslist {sApp}"
[ ]
[ ] //sPID = ""
[ ]
[-] do
[ ]
[ ] iSleepTime = 50 //Seconds
[+] if (IsNull (iKillTimeLimit))
[ ] iKillTimeLimit = 6 // Seconds.
[ ]
[ ]
[ ] iCount = (iKillTimeLimit/iSleepTime) * 100 + 1+10
[ ]
[-] for iTimes=1 to iCount
[+] if (! gbAppKill)
[ ] Print ("gbAppKill is FALSE and exiting from Spawn thread..")
[ ] break
[ ]
[ ]
[ ] Sleep (iSleepTime)
[ ]
[ ]
[ ] Print ("Executing command: {sCommand}")
[ ] SYS_Execute (sCommand, lsOutput)
[ ] ResPrintList ("Command Output", lsOutput)
[ ]
[+] for iItem=2 to ListCount (lsOutput)
[ ] sItem = lsOutput[iItem]
[+] if (MatchStr ("{sApp}*",sItem))
[ ]
[ ] sSec = GetField (sItem,":",5)
[ ]
[+] if (IsNull(sSec) || (Trim(sSec) == ""))
[ ] continue
[+] else
[ ] sTime = GetField (sItem,":",3)
[ ] sMin = GetField (sItem,":",4)
[ ] sHour = SubStr (sTime,Len(sTime)-3)
[ ]
[ ] Print ("Hour: {sHour}")
[ ] Print ("Minutes: {sMin}")
[ ] Print ("Seconds: {sSec}")
[ ] iTotalValue = Val (sMin) * 60 + Val(sHour) * 3600
[ ] Print ("App {sApp} - running total time: {iTotalValue} Seconds")
[ ]
[+] if (iKillTimeLimit <= iTotalValue)
[ ] Print ("Application {sApp} is running {iTotalValue} seconds -beyond expected time {iKillTimeLimit} seconds.")
[ ] KillApp_psKill (sApp)
[ ] Print ("Going to kill Application {sApp}")
[ ] // break // It is suitable for testcase level
[+] else
[ ] Print ("Application {sApp} is running {iTotalValue} seconds - not exceeding expected time {iKillTimeLimit} seconds.")
[ ] // return sPID
[ ]
[ ]
[ ]
[+] except
[ ] // Do Nothing
[ ]
[ ]
[ ]

Sunday, September 28, 2008

Children objects has negative co-ordinates in Browserchild

Last year, one web based product has been revamped with our own reporting modules. Lot of javascripts used for this reporting. Silktest is able to identify the HtmlTable and HtmlColumn objects properly. But the co-ordinates are shown wrong. Each click action is done in different point instead of expected point. Only X-Axis position got changed. See the RECT info below.

BrowserChild (Parent) rect: {195, 175, 827, 538}
Htmltable rect: {-77, 323, 818, 574}


It is varying for different kind of reports. Testcases need to do left-mouse click and right-mouse clicks. I have set few variables for position changes. I have written the code like below. In the Runtime, XAxis changes (ixGridInc) are calculated dynamically. I have given the code below:

4Test code - To set the Table position dynamically


[-] void SetGridTablePosChanges (Window wTable)
[ ] // To set xAxis and YAxis increments (changes)
[ ] // Position changes.
[ ] Window wParent
[ ] Boolean bxGetPos = FALSE
[ ] String sWinTag, sMainFrameTag
[ ]
[ ] RECT rtTblCell = wTable.GetRect (TRUE)
[ ] Print ("table rect: {rtTblCell}")
[ ]
[-] if (ixGridInc == -1)
[ ] Print ("Grid xAxis increment is going to set.")
[ ] ixGridPos = rtTblCell.xPos
[ ] // iyGridPos = rtTblCell.yPos
[ ] bxGetPos = TRUE
[-] else if (ixGridPos != rtTblCell.xPos)
[ ] bxGetPos = TRUE
[ ] ixGridPos = rtTblCell.xPos
[ ] // iyGridPos = rtTblCell.yPos
[-] else
[ ] Print ("Already Grid xAxis increment is available.")
[ ]
[-] if (bxGetPos)
[ ]
[ ] sMainFrameTag = WindowTag (wTable)
[ ] sWinTag = GetField (sMainFrameTag,"[BrowserChild]",3)
[ ] Print ("Whole Table tag: {sMainFrameTag}")
[ ] Print ("Parent tag: {sWinTag}")
[-] if (MatchStr ("*[6]*",sWinTag) || MatchStr ("*mainFram*",sWinTag))
[ ] wParent = MyReportPage
[ ] RECT rtTblCell2 = wParent.GetRect (TRUE)
[ ] Print ("Parent rect: {rtTblCell2}")
[ ]
[-] if ((rtTblCell.xPos < (rtTblCell2.xPos + XAXIS_TABLE_DIFF)) )
[ ] ixGridInc = rtTblCell2.xPos - (rtTblCell.xPos) + XAXIS_TABLE_DIFF
[ ] Print ("X Axis changed Position: {ixGridInc}")
[-] else
[ ] Print ("Parent{wParent} is not expected one.")

Saturday, August 30, 2008

Converting Bitmap to GIF/JPG image

Earlier I have written a post about Automation Basics - Capturing Failures . Almost all the GUI testing tools are providing built-in functions to take the snapshot of screen. Snapshot can be taken for given screen co-ordinates or entire object.

Mostly these snapshots are stored as bitmap (*.bmp) files. Bitmap files are occupying more hard-disk space. It is difficult to maintain all the snapshots for each build in release-wise. IrfanView is a windows graphic viewer and it is a freeware utility. It has many command-line options for image related actions. You can just copy the executable file to another machine and can open or use immediately.

Syntax to Convert one image to another image format:
/convert=filename - convert input file to 'filename' and close IrfanView

Below I have given the way to implement in Silktest. This can be done for any testing tool.



[ ] //convert the image
[ ] SYS_Execute ("D:\autostuff\i_view32.exe {sBmpImage} /silent /convert={sGifImage}")