Automation Testing, Manual Testing, QTP/UFT 11 , QC/ALM 11 ,SAP TAO, Unix, Selenium, Oracle SQL, Shell Scripting and For Online Trinings to contact me : Cell:+91-8897972059 , Email Id : quicktestprotech@gmail.com

Friday, August 22, 2014

Import XLSX Sheet to UFT/QTP Datatable

Import XLSX Sheet to UFT/QTP Datatable



Most of the people are facing problem with one of the major limitation of QTP/UFT. That is importing data from XLSX extension files. QTP/UFT does not support directly Import option below QTP/UFT 12 versions But using Excel Object Model we can overcome this problem.UFT 12 and above version can support this XLSX extension files.


The below function will import the data from XLSX file to QTP/UFT specified data sheet.

Function ImportSheetFromXLSX(dFileName,dSourceSheetName,dDestinationSheetName)  
  
  Dim ExcelApp  
  Dim ExcelFile  
  Dim ExcelSheet  
  Dim sRowCount  
  Dim sColumnCount  
  Dim sRowIndex  
  Dim sColumnIndex  
  Dim sColumnValue  
  
  Set ExcelApp=CreateObject("Excel.Application")  
     Set ExcelFile=ExcelApp.WorkBooks.Open (dFileName)  
     Set ExcelSheet = ExcelApp.WorkSheets(dSourceSheetName)  
  
  Set qSheet=DataTable.GetSheet(dDestinationSheetName)  
  
  sColumnCount= ExcelSheet.UsedRange.Columns.Count  
  sRowCount= ExcelSheet.UsedRange.rows.count  
  
  For sColumnIndex=1 to sColumnCount  
  
    sColumnValue=ExcelSheet.Cells(1,sColumnIndex)  
    sColumnValue=Replace(sColumnValue," ","_")  
  
    If sColumnValue="" Then  
     sColumnValue="NoColumn"&sColumnIndex  
    End If  
  
    Set qColumn=qSheet.AddParameter (sColumnValue,"")  
  
    For sRowIndex=2 to sRowCount  
     sRowValue=ExcelSheet.Cells(sRowIndex,sColumnIndex)  
     qColumn.ValueByRow(sRowIndex-1)=sRowValue  
    Next  
  
  Next  
  Set ImportSheetFromXLSX=qSheet  
   ExcelFile.Close  
   ExcelApp.Quit  
End Function


There is also another way of overwriting Datatable object to import XLSX files. This is useful for the projects which are already used Datatable.ImportSheet in such many places and now they want to enable XLSX support without modifying QTP/UFT script. Below is the example on how to over write datatable object with newly created class. If you use below code you need to update all existing QTP/UFT datatable object methods and properties.

EnableXLSXsupport()  
DataTable.ImportSheet "C:\Users\thirupathi\Desktop\Data\test.xlsx","Sheet2","Action1"  
  
'********************************************************************************************************  
Function EnableXLSXsupport()  
  
 ExecuteGlobal "Dim QTPDataTable"  
   
 Set QTPDataTable=Datatable  
 ExecuteGlobal "Dim Datatable"  
   
 Set Datatable=New CustomDatatable  
  
End Function  
'********************************************************************************************************  
Class CustomDatatable  
  
 Function ImportSheet(dFileName,dSourceSheetName,dDestinationSheetName)  
  
  Dim ExcelApp  
  Dim ExcelFile  
  Dim ExcelSheet  
  Dim sRowCount  
  Dim sColumnCount  
  Dim sRowIndex  
  Dim sColumnIndex  
  Dim sColumnValue  
  
  Set ExcelApp=CreateObject("Excel.Application")  
     Set ExcelFile=ExcelApp.WorkBooks.Open (dFileName)  
     Set ExcelSheet = ExcelApp.WorkSheets(dSourceSheetName)  
  
  Set qSheet=QTPDataTable.GetSheet(dDestinationSheetName)  
  
  sColumnCount= ExcelSheet.UsedRange.Columns.Count  
  sRowCount= ExcelSheet.UsedRange.rows.count  
  
  For sColumnIndex=1 to sColumnCount  
  
    sColumnValue=ExcelSheet.Cells(1,sColumnIndex)  
    sColumnValue=Replace(sColumnValue," ","_")  
  
    If sColumnValue="" Then  
     sColumnValue="NoColumn"&sColumnIndex  
    End If  
  
    Set qColumn=qSheet.AddParameter (sColumnValue,"")  
  
    For sRowIndex=2 to sRowCount  
     sRowValue=ExcelSheet.Cells(sRowIndex,sColumnIndex)  
     qColumn.ValueByRow(sRowIndex-1)=sRowValue  
    Next  
  
  Next  
   'Set Datatable=QTPDataTable  
   ExcelFile.Close  
   ExcelApp.Quit  
   'Set QTPDataTable=Nothing  
 End Function  
'********************************************************************  
 Function AddSheet(shtName)  
   Set AddSheet=QTPDataTable.AddSheet(shtName)  
 End Function   
'********************************************************************  
End Class  



If you uncomment the Set Datatable=QTPDatatable and Set QTPDatatable =Nothing then this function only works for once. When ever you want to import XLSX sheet then you need to call EnableXLSXsupport() before you use import sheet. This way is for the experts who can handle overwriting of reserved objects. Do remember that If you have not uncommented, the existing datatable methods will not work and you need to define each method in customdatatable class in order to work. You can observe the "AddSheet" method in the above class example

Wednesday, August 13, 2014

How to change the order of Test Plan fields in Quality Center?


Using workflow to change the order of Test Plan fields
Custom workflow is required to change the order of the fields in the Test Plan module. The order is changed using the ViewOrder property.
The ViewOrder must be modified in both the Test_New and Test_MoveTo subroutines.
Fields are displayed Left to Right, Top to Bottom.
See the example below.
Sub Test_New  Remember to also include in the Test_MoveTo subroutine
  • ...
  • Test_Fields("TS_NAME").ViewOrder=10  
     'Test Name fieldTest_Fields("TS_TEST_ID").ViewOrder=20  
      'Test ID fieldTest_Fields("TS_USER_03").ViewOrder=30  
     'Test Focus fieldTest_Fields("TS_USER_04").ViewOrder=40  
     'Test Risk fieldTest_Fields("TS_USER_05").ViewOrder=50  
     'Critical Path fieldTest_Fields("TS_USER_06").ViewOrder=60  
    Test Use fieldTest_Fields("TS_USER_07").ViewOrder=70   
     'Estimated Test Duration
    
  • Test_Fields("TS_RESPONSIBLE").ViewOrder=80 'Designer
  • Test_Fields("TS_USER_01").ViewOrder=90  
      'Created in Project fieldTest_Fields("TS_USER_02").ViewOrder=100  
      'Modified in Project fieldTest_Fields("TS_CREATION_DATE").ViewOrder=110 'Creation Date
    
  • ...
  • End Sub
  • Error when adding a User Defined Field, v11.52


    Error when adding a User Defined Field, v11.52


    When trying to add a custom user defined field in a project that was created originally in Quality Center 9.2 or earlier, a memory protected or corrupted error may occur.
    Workaround:
    Run the following query on the project's schema:
    For SQL Server:
    UPDATE td.SYSTEM_FIELDSET SF_ROOT_ID=NULLWHERE SF_ROOT_ID = 0 ANDSF_COLUMN_NAME <> 'CF_FATHER_ID' ANDSF_COLUMN_NAME <> 'CY_FOLDER_ID'
    For Oracle:
    UPDATE .SYSTEM_FIELDSET SF_ROOT_ID=NULLWHERE SF_ROOT_ID = 0 ANDSF_COLUMN_NAME <> 'CF_FATHER_ID' ANDSF_COLUMN_NAME <> 'CY_FOLDER_ID'

    Limit Test Plan field change


    Limit Test Plan field change


    First create a new user field in Test under Project Entities in Project Customization. This is the field that we will use to hold the user that last changed the field to “Design” once that user has changed the value to Design they should not be able to change the status again. In a sense what we are doing is locking the test when it is changed to “Design” so that the user that last made the change might not try to circumvent the rules by changing the status to something else and then try and jump straight to “Ready”
    I created a field to hold the value of the user that last changed the test to Design so that we can see who changed the status to “Design”, in the workflow I made the field read only so that a user might not try to change the field to “circumvent the rules” of the code and change the value of the Status field. In my environment this field name was ”TS_USER_01” you will need to replace this value in the code with the name of the field that you use to hold the user name.
    In the select case you will need to change the values to match what you have for your “Plan Status” project list, they currently have entries for my “Plan Status” project list. You should not need to include “Design” since it does not matter if the field is changed from “Design” back to “Design” just so that it is not changed to any other status.
    Note: This is just an example, use code at your own risk, you will need to change this code to apply to your environment
    In the workflow code (place the code pieces into the same subs that I did):
    1. Sub Test_MoveTo
    2. On Error Resume Next
    3. Test_Fields.field("TS_USER_01").IsReadOnly=true
    4. On Error GoTo 0
    5. End Sub
    6.  
    7. Sub Test_FieldChange(FieldName)
    8. On Error Resume Next
    9. 'This sets the user name field to the user name that changes the status to "Design"
    10. If Test_Fields.field("TS_STATUS").IsModified=true then
    11. if Test_Fields.field("TS_STATUS").Value = "Design" then
    12. Test_Fields.field("TS_USER_01").IsReadOnly=false
    13. Test_Fields.field("TS_USER_01").Value = User.UserName
    14. Test_Fields.field("TS_USER_01").IsReadOnly=true
    15. end if
    16. End If
    17.  
    18.  
    19. On Error GoTo 0
    20. End Sub
    21.  
    22.  
    23. Function Test_FieldCanChange(FieldName, NewValue)
    24. On Error Resume Next
    25.  
    26. 'This select case ensures that the user that last changed the status to "Design" can no longer
    27. 'change the status of the test. Each case other than "Design" needs an option so that the user
    28. 'cannot change the status once they have changed it to "Design"
    29. Test_FieldCanChange = DefaultRes
    30. Select Case NewValue
    31. Case "Ready"
    32. If FieldName="TS_STATUS" and Test_Fields.field("TS_USER_01").value = user.UserName then
    33. msgbox "Current user has already changed the status to Design and cannot change current status"
    34. Test_FieldCanChange=FALSE
    35. End If
    36. Case "Imported"
    37. If FieldName="TS_STATUS" and Test_Fields.field("TS_USER_01").value = user.UserName then
    38. msgbox "Current user has already changed the status to Design and cannot change current status"
    39. Test_FieldCanChange=FALSE
    40. End If
    41. Case "Repair"
    42. If FieldName="TS_STATUS" and Test_Fields.field("TS_USER_01").value = user.UserName then
    43. msgbox "Current user has already changed the status to Design and cannot change current status"
    44. Test_FieldCanChange=FALSE
    45. End If
    46. End Select
    47.  
    48.  
    49. On Error GoTo 0
    50. End Function

    How to retreive TestLab execution report using Excel Reports


    How to retreive Test Lab execution report using Excel Reports



    The below query will give you the Testlab execution report wrt Testlab folder Id's


    Select CF_ITEM_NAME FOLDER,
    CY_CYCLE TESTSET_NAME,
    TEST.TS_NAME TEST_SCRIPT,
    RUN.RN_RUN_NAME RUN_NAME,
    RN_RUN_ID RUN_ID,
    RN_STATUS RUN_EXECUTION_STATUS,
    RN_TESTER_NAME LAST_TESTER_NAME ,
    RUN.RN_EXECUTION_DATE,
    TEST.TS_TEST_ID

    From CYCLE,RUN,TEST,TESTCYCL, CYCL_FOLD
    Where CYCLE.CY_FOLDER_ID=CYCL_FOLD.CF_ITEM_ID
    AND TESTCYCL.TC_CYCLE_ID=CYCLE.CY_CYCLE_ID
    AND TEST.TS_TEST_ID=TESTCYCL.TC_TEST_ID
    AND RUN.RN_CYCLE_ID=TESTCYCL.TC_CYCLE_ID
    AND TEST.TS_TEST_ID=RUN.RN_TEST_ID
    AND (CYCLE.CY_FOLDER_ID in ('23772')) /*Enter the folder Id of TestLab tree */

    Quality Center / ALM site admin password change oracle

    Quality Center / ALM  site admin password change oracle


    Changing the Site Administrator Schema password for QC installed on Oracle The Site Administrator connects to the Site Admin schema by decrypting the password in the td_siteadmin.xml file, then connects to the database back-end using the decrypted password. Since there is no direct way of changing the Site Admin schema, the instructions below will demonstrate how to generate a new encrypted password and insert that into the td_siteadmin.xml file. An update query will also be needed to change the schema password from the database back-end.Oracle:1. Determine the name of the Site Admin schema.
    1. Log into the Site Administrator.
    1. Navigate to the Site Config tab.
    1. Make a note of the BASE_REPOSITORY_PATH. This is the location of your project repository.
    2.  Example:
      C:\Program Files\Mercury Interactive\Quality Center\repository
    1. C:\Program Files\Mercury Interactive\Quality Center\repository
    1. On the Application Server, navigate to the directory noted in step 1c.
    1. Open the dbcon.txt file under BASE_REPOSITORY_PATH\qc.
    1. Make a note of the database connection string.
    2.  Example:
      qcsiteadmin_db@OracleServer.1521.ORCL
    1. qcsiteadmin_db@OracleServer.1521.ORCL
    1. Note:
    1. The database schema is the first element in the connection string.
    2. Create a new database server to get the encryption for the desired password.
    1. Log into the Site Administrator.
    1. Navigate to the DB Servers tab.
    1. Click <New>, and create a new "dummy" database server. You can specify any values you want except the DB Admin Password should be set to the desired password for site admin schema.
    2.  Example
      TEMPORASERVER
    1. TEMPORASERVER
    1. Log into Oracle (SQL Plus) using the Site Admin schema user (the user name found from step 1f).
    2.  Note:
      Please contact 
    1. Please contact 
    2. HP Support to obtain the default password.
    1. Run a query on the dbservers table to locate the row corresponding to the dbserver creates in step 2c, and view the column DB_ADMIN_PASSWORD.
    2.  Example:
      select DB_ADMIN_PASSWORD from dbservers where dbserver_name like 'TEMPORASERVER'
    1. select DB_ADMIN_PASSWORD from dbservers where dbserver_name like 'TEMPORASERVER'
    1. Note:
    1. You will need to make a note of the value specified in this column (it will in format TWO:111-111-11-.....).
    3. Stop Quality Center.4. Edit the siteadmin.xml file, and replace the value inside the <DefaultUserPassword> tag with the value noted in step 2e. 5. In the Oracle back-end, change the password for the Site Admin schema user to match the password specified in step 2c.Example:update user qcsiteadmin_db identified by <newpassword>Note: You will need to replace the qcsiteadmin_db with the name of your Site Administrator schema noted in step 1f.6. Restart Quality Center.

    Quality Center / ALM LDAP


    Quality Center LDAP

    How to change the authentication from LDAP to Quality Center when LDAP server is down?

    Below are the steps to change the Authentication from LDAP to QC.
    1.In the qcsiteadmin_db database, find the PARAMS table.
    2. Look for the record where PARAM_NAME = 'Authentication'. Change the PARAM_VALUE to 'QualityCenter'.
    3. Look for records where PARAM_NAME starts with 'LDAP', and delete all of them except one 'LDAP_SEARCH_USER_CRITIRIA'.
    4. Restart the Quality Center service using the Quality Center icon in system tray.
    5. Users should be able to log in using Quality Center authentication.
     

    Loading...