Wednesday

Solution to "this test is locked by another quality center user"


There are a lot of instances while working with Quality center that you might have noticed this message "this test is locked by another quality center user”
Sometimes you may have imposed a self lock on it.. J This happens mostly when the user kills the QTP process when the script is still open(from QC).

If you have forgotten the machine where you have imposed a self lock then don’t worry as here is the soln to get rid of the same:

Copy the following code and run it from the machine were qc is instantiated.

On Error Resume Next   
desc = "Please provide the network id for the user, and please make sure" &_
        "this user is logged out prior to removing locks"   
UName = InputBox(desc,"Provide network id")  
If(UName <> "") Then     
  Set cmd = TDConnection.Command      
  cmd.CommandText = "DELETE FROM Locks WHERE LK_USER = '" & UName & "'"       
  cmd.Execute      
  MsgBox "All locks for user id: " & UName & " were removed", _       
    vbNotify+vbOKOnly,"Compelted"  
Else    
  MsgBox "No locks were changed", vbNotify+vbOKOnly, "No Info" 
End If   
On Error Goto 0

Provide your userid when prompted and wallah , the magic is done J
You can now go ahead and edit your scripts.
Happy Testing!

Thursday

Maximize browser using QTP and IE8 / IE7 / Firefox


Problem : Maximize a tabbed browser (ie7/ie8/firefox)
Solution1:  hwnd=Browser("name:=myBrowser").getROProperty("hwnd")
               Window("hwnd:="&hwnd").Maximize
Disadvantage:  Does not work with tabbed browsers consistently

Solution2: hwnd=Browser("name:=myBrowser").Object.HWND
              Set objWindow=Window("hwnd:="&hwnd2)
              objWindow.Maximize
Disadvantage:  Does not work with tabbed browsers when there are multiple browsers open
 

Solution3:
SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe",URL,"C:\","open","3"

The "3" at the end Activates and Maximizes the window.
Disadvantage:  Does not work when the browser is already open 


Solution4: Set WshShell = CreateObject("WScript.Shell")
               'Alt Space X - shortcut to maximize ie browser.
                WshShell.SendKeys "% x"

Hope this helps as always :)
Happy Testing!