Wednesday, May 17, 2017

Enable ‘Create a new Excel report’ option in HP-ALM

Excel Reports in Quality Center or HP-ALM have always been quite useful in extracting various reports. One of the many advantages has been to export test cases from ALM to excel sheet for convenient use and reporting

From HP-ALM version 12, the option to ‘Create New Excel Report’ is disabled by default. It means, the user cannot create new excel report, but can view, edit and run existing reports (if any) from previous versions.

ALM: Create New Excel Report Option Missing
ALM: Create New Excel Report Option Missing

ALM: Existing Excel Reports
ALM: Existing Excel Reports

 However, the option to ‘Create New Excel Report’ can be enabled by site configuration parameter – ‘ENABLE_CREATE_LEGACY_EXCEL_REPORT’. Following are the steps to do so:
  1. Login to ALM site administration.
  2. Navigate to ‘Site Configuration’ tab.
    ALM: Site Admin Site Configuration
    ALM: Site Admin Site Configuration
  3. Look for the parameter – ‘ENABLE_CREATE_LEGACY_EXCEL_REPORT’. Double click to configure it.
  4. If the above parameter is not found, the site admin can create it by clicking ‘New’. Enter the details as below.
    ALM: Site Admin Site Configuration New Parameter
    ALM: Site Admin Site Configuration New Parameter
  5. Please note that the parameter name is case sensitive and must be entered in all Capital letters.
  6. Click Ok.
ALM: Site Admin Site Configuration Excel Report Parameter
ALM: Site Admin Site Configuration Excel Report Parameter


The users must log off and login again in order to see the changes being effective.


ALM: Create New Excel Report Option Enabled
ALM: Create New Excel Report Option Enabled

Monday, April 24, 2017

SAP Warning Message - "A script is attempting to access/attach SAP GUI" Upon Running Automated Script

While running an automated script on SAP GUI, a warning message – “A script is attempting to access SAP GUI” is displayed.




In some cases, the message can also be – “A script is trying to attach to GUI“. The solution to both is same.
This warning can be disabled with following steps:
  1. Launch to your SAP GUI application manually.
  2. Navigate to ‘Options’ as below or press “Alt F12” and click ‘Options.

  3. Select “Accessibility & Scripting”.



  4. Expand ‘Accessibility & Scripting’ and select “Scripting”.



  5. If the warning message is being thrown, the option “Notify when a script attaches to SAP GUI” would be checked. Un-check following options:
    1. Notify when a script attaches to SAP GUI
    2. Notify when a script opens a connection. Click “Apply” followed by “OK”.

  6. Please note that since the notification is now disabled, care must be taken to prevent the system from plausible threats and unwanted applications.

Thursday, March 23, 2017

Difference between "=" and "==" in Java


One liner answer to this question would be:
“=” operator is for assigning a value to a variable whereas “==” operator compares the objects’ location(s) with respect to memory.

Thus,
"=" is an simple Assignment Operator which assigns values of variable on it's right side variable to the left side operand.
"==" is a Relational Operator which checks if the values of two variables are equal or not. If yes then condition returns true otherwise, it returns false.

For example, below code explain the operators on primitive variables like int, float etc.
Primitive types are the most basic data types available within the Java language. There are 8: boolean , byte , char , short , int , long , float and double . These types serve as the building blocks of data manipulation in Java.

public void testMain(Object[] args)
{
                int a = 5;
                int b = 5;

                int c = a+b;
                System.out.println("c=" + c); //This statement would print 10

                int d = a;
                System.out.println("d=" + d); //This statement would print 5

                int e = c;
                System.out.println("e=" + e); //This statement would print 10

                if(a==b)
                                System.out.println("True");
                else
                                System.out.println("False");
                //The above would print True: a=b=5
                                               
                if(a==c)
                                System.out.println("True");
                else
                                System.out.println("False");
                //The above would print False: a=5 & c=10
                                               
                if(a==d)
                                System.out.println("True");
                else
                                System.out.println("False");                 
                //The above would print True; a=5, d=a=5(as initialized above), thus a=d
}

Thus, output of above piece of code is:
c=10
d=5
e=10
True
False
True


Let's learn some basics on 'char' first before proceeding to the example with 'char' variables. 'char' is a primitive type, and it can hold a single character or a Unicode/ASCII value.

public void testMain(Object[] args)
{
                char a = '5';
                System.out.println("Value of variable a=" + a);
                System.out.println("ASCII value of variable a=" + (int) a);
                                               
                char b = '5';
                System.out.println("\nValue of variable b=" + b);
                System.out.println("ASCII value of b=" + (int) b);

                char c = 'j';
                System.out.println("\nValue of variable c=" + c);
                System.out.println("ASCII value of c=" + (int) c);
                                               
                char d = (char) (a+b); //first adds the ASCII values of variables a and b which is 53+53=106; and then convert that ASCII value to it's corresponding character which is 'j'.
                System.out.println("\nValue of variable d=" + d);
                System.out.println("ASCII value of d=" + (int) d);

                char e = a;
                System.out.println("\nValue of variable e=" + e); //This statement would print 5

                                               
                if(a==b)
                                System.out.println("True");
                else
                                System.out.println("False");
                //The above would print True: a=b='5'
                                               
                if(a==c)
                                System.out.println("True");
                else
                                System.out.println("False");
                //The above would print False: a='5' & c='j'
                                               
                if(a==e)
                                System.out.println("True");
                else
                                System.out.println("False");                 
                //The above would print True; a='5', e=a='5'(as initialized above), thus a=e
}

Here is the output of above piece of code:
Value of variable a=5
ASCII value of variable a=53

Value of variable b=5
ASCII value of b=53

Value of variable c=j
ASCII value of c=106

Value of variable d=j
ASCII value of d=106

Value of variable e=5
True
False
True

Below code explains the operators on reference variables like string.
public void testMain(Object[] args)
{
                String a = "Smile"; //This statement creates a String Literal which points to a memory location in the String pool (which is shared) if it already exists. If it does not exists, it createsa new.
                String b = new String("Smile"); //This statement creates a String Object in the heap memory which is not shared.
                               
                if(a==b)
                                System.out.println("True");
                else
                                System.out.println("False");
                //this prints "False" because variable a and b are pointing to different memory locations.
                               
                String c = "Smile"; //This statement would store variable c in the same memory location as variable a
                if(a==c)
                                System.out.println("True");
                else
                                System.out.println("False");
                //Since both a and c points to same memory location, thus having same data, it prints True
                               
                                                               
                if(c=="5")
                                System.out.println("True");
                else
                                System.out.println("False");
                //This comparision creates a new memory location for undeclared data "5". Thus it would print false                                                          
                               
}

Below is the output of above piece of code
False
True
False

Thus, the statement we gave in the beginning is actually correct but incomplete. The key to understanding here is the last word 'memory'.

So, the complete one line answer to the question would be:


“=” operator is for assigning a value to a variable whereas “==” operator compares the objects’ location(s) in memory (Not the value).

Monday, November 21, 2016

HP QC/ALM Create Project - 'failed to get tablespace info'

This is the second time I faced this issue and actually scolded myself for not documenting before. Here goes the problem.

When when the user click 'Next' on following step:


Following error message is displayed:



This is generally because of the password mismatch for 'System' user in corresponding Database.

The user need to contact the Database Administrator ion order to get the issue resolved (DBA team generally does not share the password for 'System' user.).

Following information is needed while contacting the DB:
1. Server Name - Displayed on the window above.

Sometimes. the DBA might also ask for the connection string or the 'SID' for the Database server. The same can be fetched from:
QC SiteAdmin -> DB Servers


Following are the steps to update the password:
1. Select the required DB server from left panel.
2. Click on 'Database Administrator Password'. Following window would be displayed.
HP-QC-ALM-Update-Datadase-Admistrator-Password

3. Ask the DBA to input latest DB password for System user and click OK.
4. Click at ''Connection String'. Following window would be displayed.

5. Click on 'Test Connection'. Following window would be displayed.



6. Do not update the password (It would be automatically updated) and click OK.
7. If the password is correct and connection is established, message 'The Connection String is Ok' is displayed as below: 
                                                      

8. Click OK, Close the 'Ping DB Server' popup and Connection string editor window.
9 Go back to 'Site Projects' and try creating a project again. HP-ALM should now successfully pass through the erroneous step as mentioned above.


Thursday, May 26, 2016

Apache POIXML Exception: InvalidFormatException

Problem:
I received following error while using “Apache POI(XSSF API)” for reading xlsx file”.
Exception occurred during playback of script [TC002_Login] [CRFCN0019E: RationalTestScriptException on line 45 of script TC002_Login - org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13].].

Below is the error displayed in log file:
  • exception_name = org.apache.poi.POIXMLException
  • exception_message = org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
  • script_name = TC002_Login
  • script_id = TC002_Login.java
  • line_number = 45
exception_stack = at org.apache.poi.util.PackageHelper.open(PackageHelper.java:41)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:204)
at SuperHelperClass.SuperScriptHelperlibrary.updateExcelReportScriptname(SuperScriptHelperlibrary.java:1018)
at TC002_Login.testMain(TC002_Login.java:45)

at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
at org.eclipse.core.launcher.Main.main(Main.java:34)
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:178)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:662)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:269)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39)

Line number 45 read:
updateExcelReportScriptname(DestReport); //DestReport is a string variable with path+filename
The function ‘updateExcelReportScriptname’ is defined as below:
public void updateExcelReportScriptname(String DestReport)
{
                        FileInputStream file;

                        try {
                                    file = new FileInputStream(DestReport);
                                    XSSFWorkbook workbook;
                                    try {
                                                workbook = new XSSFWorkbook(file); //Line NUmber 1018
                                                XSSFSheet mySheet1 = workbook.getSheetAt(0);
                                                XSSFRow myRow1 = null;
                                                XSSFCell myCell1 = null;

                                                XSSFCellStyle style = workbook.createCellStyle();
                                                style.setAlignment(CellStyle.ALIGN_JUSTIFY);
                                                style.setFillPattern(CellStyle.SOLID_FOREGROUND);
                                                style.setBorderBottom(CellStyle.BORDER_THIN);
                                                style.setBorderTop(CellStyle.BORDER_THIN);
                                                style.setBorderRight(CellStyle.BORDER_THIN);
                                                style.setBorderLeft(CellStyle.BORDER_THIN);
                                                style.setWrapText(true);

                                                String excelData1[][] = new String[500][500];

                                                int row = mySheet1.getPhysicalNumberOfRows();

                                                excelData1[row][0] = getScriptName();
                                                myRow1 = mySheet1.createRow(row);
                                                myCell1 = myRow1.createCell(0);
                                                myCell1.setCellValue(excelData1[row][0]);
                                                style.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
                                                myCell1.setCellStyle(style);

                                                for(int cellNum = 1; cellNum <= 19; cellNum++)
                                                {
                                                            XSSFCell myCell = null; 
                                                            myCell = myRow1.createCell(cellNum);
                                                            myCell.setCellValue("");
                                                }
                                                file.close();       
                                                FileOutputStream outFile =new FileOutputStream(DestReport); 
                                                workbook.write(outFile);  
                                                outFile.close();

                                    } catch (IOException e) {
                                                // TODO Auto-generated catch block
                                                e.printStackTrace();
                                    }   

                        } catch (FileNotFoundException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                        }
            }
Solution:
There are two reasons I could analyse which may cause this error:
1. When I try to read ‘.xls’ file with my code and for ‘.xlsx’ files. There are different classes for xls and xlsx files namely:
Classes to be used for XLS file: HSSFWorkbook & HSSFSheet
Classes to be used for XLSX file: XSSFSheet & XSSFSheet
Required one must be used accordingly.
2. Sometimes, the same error is thrown even when the correct file format is used. The reason for this could be any of the below:
  • File is password protected
  • File is corrupted. For me, this was the case and I realized it when I tried to open the file and got bellow error. 

Microsoft Excel Error for Corrupt File

 Hope this helps solve the problem.