Quantcast
Channel: Pochampalli IT Labs
Viewing all 261 articles
Browse latest View live

Angular Gauge fusion widget demo in jasper reports (7.1.1 studio)

$
0
0
Sample output





JRXML (Copy paste this below xml in your environment)


<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 7.2.0.final using JasperReports Library version 6.6.0  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="GAUGES_Chart" pageWidth="800" pageHeight="842" columnWidth="760" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="81251d9d-a3bb-4e53-83dc-72425b025624">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<property name="ireport.jasperserver.url" value="http://localhost:8080/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.report.resource" value="/Explore/GAUGES_Report_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/Explore/GAUGES_Report"/>
<subDataset name="Dataset1" uuid="dbf58f8c-bb29-4b1f-97db-7262c4f2aa8d">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<queryString language="SQL">
<![CDATA[SELECT 35 AS value1]]>
</queryString>
<field name="value1" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="value1"/>
</field>
</subDataset>
<subDataset name="Dataset2" uuid="3af570a8-707d-43e0-8e46-4a1ccae7f95c">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<queryString language="SQL">
<![CDATA[SELECT 56 AS value2]]>
</queryString>
<field name="value2" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="value2"/>
</field>
</subDataset>
<subDataset name="Dataset3" uuid="290f42ab-46fb-461d-9d52-b47439cce88b">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<queryString language="SQL">
<![CDATA[SELECT 67 AS value3]]>
</queryString>
<field name="value3" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="value3"/>
</field>
</subDataset>
<subDataset name="Dataset4" uuid="b0869fcd-44a9-4ee3-abe5-285a2ce32f3f">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<queryString language="SQL">
<![CDATA[SELECT 50 AS value4]]>
</queryString>
<field name="value4" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="value4"/>
</field>
</subDataset>
<queryString language="SQL">
<![CDATA[select 1 as One]]>
</queryString>
<field name="one" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="one"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="543" splitType="Stretch">
<componentElement>
<reportElement x="-20" y="140" width="220" height="220" uuid="5a913c09-961e-4e39-af73-3bc70bcc96da">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<fw:angularGauge xmlns:fw="http://jaspersoft.com/fusion" xsi:schemaLocation="http://jaspersoft.com/fusion http://jaspersoft.com/schema/fusion.xsd">
<fw:widgetProperty name="gaugeStartAngle">
<fw:propertyExpression><![CDATA[225]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeEndAngle">
<fw:propertyExpression><![CDATA[-50]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="placeValuesInside">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="placeTicksInside">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeBorderThickness">
<fw:propertyExpression><![CDATA[new Integer(2)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeBorderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="label">
<fw:propertyExpression><![CDATA["TEST"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotBorderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotBorderThickness">
<fw:propertyExpression><![CDATA[new Integer(0)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotFillColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-16777216)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotRadius">
<fw:propertyExpression><![CDATA[new Integer(10)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotFillAngle">
<fw:propertyExpression><![CDATA[new Integer(5)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="upperLimit">
<fw:propertyExpression><![CDATA[new Integer(100)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="lowerLimitDisplay">
<fw:propertyExpression><![CDATA["0"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="upperLimitDisplay">
<fw:propertyExpression><![CDATA["100"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="bgColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="tickValueDistance">
<fw:propertyExpression><![CDATA[new Integer(10)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="borderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMNumber">
<fw:propertyExpression><![CDATA[10]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickValues">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showLimits">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showValue">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showShadow">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="valueBelowPivot">
<fw:propertyExpression><![CDATA[1]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickMarks">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMHeight">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMThickness">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickMarks">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="minorTMHeight">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="minorTMThickness">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="tickValueDistance">
<fw:propertyExpression><![CDATA[2]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:colorRange color="#C50F01">
<fw:minValueExpression><![CDATA[new Integer(0)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(45)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["RED"]]></fw:labelExpression>
</fw:colorRange>
<fw:colorRange color="#F9AF02">
<fw:minValueExpression><![CDATA[new Integer(46)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(65)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["YELLOW"]]></fw:labelExpression>
</fw:colorRange>
<fw:colorRange color="#00B050">
<fw:minValueExpression><![CDATA[new Integer(66)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(100)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["GREEN"]]></fw:labelExpression>
</fw:colorRange>
<dataset>
<datasetRun subDataset="Dataset1" uuid="a25baec4-2880-4216-8857-35e666a6d7a6"/>
</dataset>
<fw:dial>
<fw:dialProperty name="showValue">
<fw:propertyExpression><![CDATA[$F{value1}]]></fw:propertyExpression>
</fw:dialProperty>
<fw:dialProperty name="bgColor">
<fw:propertyExpression><![CDATA["#cc0505"]]></fw:propertyExpression>
</fw:dialProperty>
<fw:valueExpression><![CDATA[$F{value1}]]></fw:valueExpression>
</fw:dial>
</fw:angularGauge>
</componentElement>
<textField>
<reportElement x="53" y="310" width="75" height="25" uuid="642fe559-da15-4142-9c03-490cd6c7ff09"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA["LABEL"]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="250" y="0" width="220" height="220" uuid="44cb82b4-c3bf-4016-a4d1-15af0c631eae">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<fw:angularGauge xmlns:fw="http://jaspersoft.com/fusion" xsi:schemaLocation="http://jaspersoft.com/fusion http://jaspersoft.com/schema/fusion.xsd">
<fw:widgetProperty name="gaugeStartAngle">
<fw:propertyExpression><![CDATA[225]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeEndAngle">
<fw:propertyExpression><![CDATA[-50]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="placeValuesInside">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="placeTicksInside">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeBorderThickness">
<fw:propertyExpression><![CDATA[new Integer(2)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeBorderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="label">
<fw:propertyExpression><![CDATA["TEST"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotBorderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotBorderThickness">
<fw:propertyExpression><![CDATA[new Integer(0)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotFillColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-16777216)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotRadius">
<fw:propertyExpression><![CDATA[new Integer(10)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotFillAngle">
<fw:propertyExpression><![CDATA[new Integer(5)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="upperLimit">
<fw:propertyExpression><![CDATA[new Integer(100)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="lowerLimitDisplay">
<fw:propertyExpression><![CDATA["0"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="upperLimitDisplay">
<fw:propertyExpression><![CDATA["100"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="bgColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="tickValueDistance">
<fw:propertyExpression><![CDATA[new Integer(10)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="borderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMNumber">
<fw:propertyExpression><![CDATA[10]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickValues">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showLimits">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showValue">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showShadow">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="valueBelowPivot">
<fw:propertyExpression><![CDATA[1]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickMarks">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMHeight">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMThickness">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickMarks">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="minorTMHeight">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="minorTMThickness">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="tickValueDistance">
<fw:propertyExpression><![CDATA[2]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:colorRange color="#C50F01">
<fw:minValueExpression><![CDATA[new Integer(0)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(45)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["RED"]]></fw:labelExpression>
</fw:colorRange>
<fw:colorRange color="#F9AF02">
<fw:minValueExpression><![CDATA[new Integer(46)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(65)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["YELLOW"]]></fw:labelExpression>
</fw:colorRange>
<fw:colorRange color="#00B050">
<fw:minValueExpression><![CDATA[new Integer(66)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(100)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["GREEN"]]></fw:labelExpression>
</fw:colorRange>
<dataset>
<datasetRun subDataset="Dataset2" uuid="3c06cc6a-04f4-4122-b0e7-f501bd61dc14"/>
</dataset>
<fw:dial>
<fw:dialProperty name="showValue">
<fw:propertyExpression><![CDATA[$F{value2}]]></fw:propertyExpression>
</fw:dialProperty>
<fw:dialProperty name="bgColor">
<fw:propertyExpression><![CDATA["#cc0505"]]></fw:propertyExpression>
</fw:dialProperty>
<fw:valueExpression><![CDATA[$F{value2}]]></fw:valueExpression>
</fw:dial>
</fw:angularGauge>
</componentElement>
<textField>
<reportElement x="319" y="173" width="75" height="25" uuid="d49a634e-6096-4c31-bf3d-daf176d9978b"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA["LABEL"]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="540" y="130" width="220" height="220" uuid="12e0bd2a-6708-43a3-92a9-b065054fbbd7">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<fw:angularGauge xmlns:fw="http://jaspersoft.com/fusion" xsi:schemaLocation="http://jaspersoft.com/fusion http://jaspersoft.com/schema/fusion.xsd">
<fw:widgetProperty name="gaugeStartAngle">
<fw:propertyExpression><![CDATA[225]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeEndAngle">
<fw:propertyExpression><![CDATA[-50]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="placeValuesInside">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="placeTicksInside">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeBorderThickness">
<fw:propertyExpression><![CDATA[new Integer(2)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeBorderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="label">
<fw:propertyExpression><![CDATA["TEST"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotBorderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotBorderThickness">
<fw:propertyExpression><![CDATA[new Integer(0)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotFillColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-16777216)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotRadius">
<fw:propertyExpression><![CDATA[new Integer(10)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotFillAngle">
<fw:propertyExpression><![CDATA[new Integer(5)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="upperLimit">
<fw:propertyExpression><![CDATA[new Integer(100)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="lowerLimitDisplay">
<fw:propertyExpression><![CDATA["0"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="upperLimitDisplay">
<fw:propertyExpression><![CDATA["100"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="bgColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="tickValueDistance">
<fw:propertyExpression><![CDATA[new Integer(10)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="borderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMNumber">
<fw:propertyExpression><![CDATA[10]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickValues">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showLimits">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showValue">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showShadow">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="valueBelowPivot">
<fw:propertyExpression><![CDATA[1]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickMarks">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMHeight">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMThickness">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickMarks">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="minorTMHeight">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="minorTMThickness">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="tickValueDistance">
<fw:propertyExpression><![CDATA[2]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:colorRange color="#C50F01">
<fw:minValueExpression><![CDATA[new Integer(0)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(45)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["RED"]]></fw:labelExpression>
</fw:colorRange>
<fw:colorRange color="#F9AF02">
<fw:minValueExpression><![CDATA[new Integer(46)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(65)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["YELLOW"]]></fw:labelExpression>
</fw:colorRange>
<fw:colorRange color="#00B050">
<fw:minValueExpression><![CDATA[new Integer(66)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(100)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["GREEN"]]></fw:labelExpression>
</fw:colorRange>
<dataset>
<datasetRun subDataset="Dataset3" uuid="afe8028c-a5fb-4f77-90e0-3b7fd5cb1041"/>
</dataset>
<fw:dial>
<fw:dialProperty name="showValue">
<fw:propertyExpression><![CDATA[$F{value3}]]></fw:propertyExpression>
</fw:dialProperty>
<fw:dialProperty name="bgColor">
<fw:propertyExpression><![CDATA["#cc0505"]]></fw:propertyExpression>
</fw:dialProperty>
<fw:valueExpression><![CDATA[$F{value3}]]></fw:valueExpression>
</fw:dial>
</fw:angularGauge>
</componentElement>
<textField>
<reportElement x="620" y="310" width="75" height="25" uuid="5b9a8b0a-54e2-4ade-bcc7-06afc4cc6587"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA["LABEL"]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="210" y="223" width="300" height="320" uuid="97e64a44-6015-4215-b942-e3d0443aecbd">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<fw:angularGauge xmlns:fw="http://jaspersoft.com/fusion" xsi:schemaLocation="http://jaspersoft.com/fusion http://jaspersoft.com/schema/fusion.xsd">
<fw:widgetProperty name="gaugeStartAngle">
<fw:propertyExpression><![CDATA[225]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeEndAngle">
<fw:propertyExpression><![CDATA[-50]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="placeValuesInside">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="placeTicksInside">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeBorderThickness">
<fw:propertyExpression><![CDATA[new Integer(2)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="gaugeBorderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="label">
<fw:propertyExpression><![CDATA["TEST"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotBorderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotBorderThickness">
<fw:propertyExpression><![CDATA[new Integer(0)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotFillColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-16777216)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotRadius">
<fw:propertyExpression><![CDATA[new Integer(10)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="pivotFillAngle">
<fw:propertyExpression><![CDATA[new Integer(5)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="upperLimit">
<fw:propertyExpression><![CDATA[new Integer(100)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="lowerLimitDisplay">
<fw:propertyExpression><![CDATA["0"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="upperLimitDisplay">
<fw:propertyExpression><![CDATA["100"]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="bgColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="tickValueDistance">
<fw:propertyExpression><![CDATA[new Integer(10)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="borderColor">
<fw:propertyExpression><![CDATA[new java.awt.Color(-1)]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMNumber">
<fw:propertyExpression><![CDATA[10]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickValues">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showLimits">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showValue">
<fw:propertyExpression><![CDATA[Boolean.TRUE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showShadow">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="valueBelowPivot">
<fw:propertyExpression><![CDATA[1]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickMarks">
<fw:propertyExpression><![CDATA[Boolean.FALSE]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMHeight">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="majorTMThickness">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="showTickMarks">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="minorTMHeight">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="minorTMThickness">
<fw:propertyExpression><![CDATA[0]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:widgetProperty name="tickValueDistance">
<fw:propertyExpression><![CDATA[2]]></fw:propertyExpression>
</fw:widgetProperty>
<fw:colorRange color="#C50F01">
<fw:minValueExpression><![CDATA[new Integer(0)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(45)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["RED"]]></fw:labelExpression>
</fw:colorRange>
<fw:colorRange color="#F9AF02">
<fw:minValueExpression><![CDATA[new Integer(46)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(65)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["YELLOW"]]></fw:labelExpression>
</fw:colorRange>
<fw:colorRange color="#00B050">
<fw:minValueExpression><![CDATA[new Integer(66)]]></fw:minValueExpression>
<fw:maxValueExpression><![CDATA[new Integer(100)]]></fw:maxValueExpression>
<fw:labelExpression><![CDATA["GREEN"]]></fw:labelExpression>
</fw:colorRange>
<dataset>
<datasetRun subDataset="Dataset4" uuid="c0182866-e95f-4e02-abc2-8e57441916be"/>
</dataset>
<fw:dial>
<fw:dialProperty name="showValue">
<fw:propertyExpression><![CDATA[$F{value4}]]></fw:propertyExpression>
</fw:dialProperty>
<fw:dialProperty name="bgColor">
<fw:propertyExpression><![CDATA["#cc0505"]]></fw:propertyExpression>
</fw:dialProperty>
<fw:valueExpression><![CDATA[$F{value4}]]></fw:valueExpression>
</fw:dial>
</fw:angularGauge>
</componentElement>
<textField>
<reportElement x="292" y="463" width="110" height="60" uuid="df95c80c-3337-407f-bc2a-17438c500313"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA["LABEL"]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>


Tip : Styled Markup for color and font size together in Jaspersoft Studio Reports

$
0
0
In J.Design  Studio: Drag a text field (not static text) and in the properties give Markup=Styled


Expression inside text field :
"<style forecolor='#ffffff' size='14'> Hi,I am red in color..!</style>"

Sample output: 

References: 
https://community.jaspersoft.com/blog/tip-half-colored-text-static-text-field-or-text-field-jasper-reports-or-basic-usage-markup

https://infosys.ars.usda.gov/svn/code/third_party/Jasper_Reports/jasperreports-4.6.0-project/jasperreports-4.6.0/dist/docs/sample.reference/styledtext/index.html

attributes supported by the <style isBold="true">style</style> 
tag used to format the text content inside a styled text element:

fontName
<style size="32">size</style>
<style isBold="true">isBold</style>
<style isItalic="true">isItalic</style>
<style isUnderline="true">isUnderline</style>
<style isStrikeThrough="true">isStrikeThrough</style>
pdfFontName
pdfEncoding
isPdfEmbedded
<style forecolor="red">forecolor</style>
<style backcolor="blue" forecolor="white" isBold="true">backcolor</style>

Tip : ampersand for Styled Markup in text field expression in Japsersoft Studio reports

$
0
0

Wrong :"<style forecolor='#ffffff' size='14'>Sadakar & Rohit </style>"

Correct :"<style forecolor='#ffffff' size='14'>Sadakar &amp; Rohit </style>"

Reason: Styled Markup takes XML symbols\syntax's

Sample output: 


Tip : Page numbers of report having sub reports in Jaspersoft Design Studio reports

$
0
0

Master/Parent Report : 
* Call all the sub reports from Master Report.
* It is not required to give any variables in Mater report to get the page numbers (at least in this example)

Sub Report-1 : 
* In Sub Report-1 drag $V{MASTER_CURRENT_PAGE} variable to the band (presuming the page number is kept in Title band in this case)
* In the variable properties, keep Evaluation Time = Master




Sub Report-2: 
  Perform the same steps as in Sub Reprot-1
Sub Report-3: 
Perform the same steps as in Sub Reprot-1
.
.
.
Sub Report-N: 
Perform the same steps as in Sub Reprot-1


Sample outputs from original example in which I did not keep page number variable for first sub report so my report is displaying page numbers starting from 2nd page.



NOTE: If you publish any of the sub report as an individual report, the report always displays page number starting from 1 

Tip : How to remove Y1 and Y2 axis labels on dual axis chart in jaspersoft studio HTML-5(high charts) ?

$
0
0
Problem Statement: 
Take a look at the below snapshot. Y1 and Y2 axis's by default gets values when you plot the data on to the chart. In this tip, you would learn how to remove these values. While exploring this example, I've revisited-how to setup conditional colors to the bars. Note that this is column spline graph.



Presuming, you have already know how to set-up dual axis and how to play with advanced properties ? If not, do not worry, copy paste the jrxm provided in professional studio and play around
a) Series bucket properties for conditional colors b) Measures Advanced properties to get Y1 and Y2 axis's b) context specific advanced properties for graph's Y1 and Y2 properties.

Since it is late in the night writing this post, I didn't want just to leave the stuff that took 3-4 days of R&D,

Most of the examples in this site works on postgresql foodmart database(that ships with jaspersoft server installation) including this one.

Removing Y1 Axis Labels
This is simple and straight forward, configure below advanced property

Removing Y2 Axis Labels
There are workarounds in high charts API with opposite=false and with style-lables-enabled=false but non of these worked effectively in studio graph. lable.style.fontSize=0 is the property that removes labels from Y2 axis


Sample output
Conditional colors of bars: 
If you want to print conditional colors for bars based on series values something like below expression should work. 

In series Bucket Properties

color=$F{series}.equals("Rating1") ? "#c00000" : ($F{series}.equals("Rating2")?"#a5a5a5":($F{series}.equals("Rating3")?"#ffc000":($F{series}.equals("Rating4")?"#4472c4":"#ffffff")))
To apply the above to measures, do not forget to give below shown for each of the measure.


Other Notes:
You may also refer to this blog post for understanding how to configure Y1 and Y2 axis's advanced properties

Playing with Advanced Properties of Dual Axis high Chart in Japser Studio 6.x or later - How to control Y axes values (min or max or common zero)

https://community.jaspersoft.com/blog/playing-advanced-properties-dual-axis-high-chart-japser-studio-6x-or-later-how-control-y-axes

JRXML: This example is developed using J.Studio 7.2 professional- preferable to use the same or later version to import this example for your studio. 
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 7.2.0.final using JasperReports Library version 6.6.0  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Dual Axis-Remove Y1_Y2_AxisLabels_XAxisLabelsWrapping" pageWidth="650" pageHeight="700" columnWidth="650" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="aad33c48-a3a4-4ab3-9120-761b1fe88d16">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<property name="ireport.jasperserver.url" value="http://localhost:8080/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.reportUnit" value="/EarthlySystems/Test/Dual_Axis_Remove_Y1_Y2_AxisLabels_XAxisLabelsWrapping"/>
<property name="ireport.jasperserver.report.resource" value="/EarthlySystems/Test/Dual_Axis_Remove_Y1_Y2_AxisLabels_XAxisLabelsWrapping_files/main_jrxml"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Dataset1" uuid="3b042c00-14be-48c4-b1ba-b74d4cedcf22">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w1" value="328"/>
<property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w2" value="665"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<queryString language="SQL">
<![CDATA[(select 'Rating1' as series, 'category1' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating2' as series, 'category1' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating3' as series, 'category1' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating4' as series, 'category1' as category, 'Number2' As rating , 1.5 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating5' as series, 'category1' as category, 'Number4' As rating , 3 as ratingValue  from customer limit 1 )

UNION ALL

(select 'Rating1' as series, 'category2' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating2' as series, 'category2' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating3' as series, 'category2' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating4' as series, 'category2' as category, 'Number2' As rating , 1.5 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating5' as series, 'category2' as category, 'Number4' As rating , 2 as ratingValue  from customer limit 1 )

UNION ALL

(select 'Rating1' as series, 'category3' as category, 'Number1' As rating , 1.5 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating2' as series, 'category3' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating3' as series, 'category3' as category, 'Number1' As rating , 1 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating4' as series, 'category3' as category, 'Number2' As rating , 1.5 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating5' as series, 'category3' as category, 'Number4' As rating , 2 as ratingValue  from customer limit 1 )


UNION ALL

(select 'Rating1' as series, 'category4' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating2' as series, 'category4' as category, 'Number1' As rating , 1 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating3' as series, 'category4' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating4' as series, 'category4' as category, 'Number2' As rating , 0.5 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating5' as series, 'category4' as category, 'Number4' As rating , 2 as ratingValue  from customer limit 1 )

UNION ALL

(select 'Rating1' as series, 'category5' as category, 'Number1' As rating , 1 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating2' as series, 'category5' as category, 'Number1' As rating , 1 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating3' as series, 'category5' as category, 'Number1' As rating , 1 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating4' as series, 'category5' as category, 'Number2' As rating , 0.5 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating5' as series, 'category5' as category, 'Number4' As rating , 3 as ratingValue  from customer limit 1 )

UNION ALL

(select 'Rating1' as series, 'category6' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating2' as series, 'category6' as category, 'Number1' As rating , 1 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating3' as series, 'category6' as category, 'Number1' As rating , 3 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating4' as series, 'category6' as category, 'Number2' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating5' as series, 'category6' as category, 'Number4' As rating , 3 as ratingValue  from customer limit 1 )

UNION ALL

(select 'Rating1' as series, 'category7' as category, 'Number1' As rating , 1.5 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating2' as series, 'category7' as category, 'Number1' As rating , 1 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating3' as series, 'category7' as category, 'Number1' As rating , 2 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating4' as series, 'category7' as category, 'Number2' As rating , 1.5 as ratingValue  from customer limit 1 )
UNION ALL
(select 'Rating5' as series, 'category7' as category, 'Number4' As rating , 3 as ratingValue  from customer limit 1 )]]>
</queryString>
<field name="series" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="series"/>
</field>
<field name="category" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="category"/>
</field>
<field name="rating" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="rating"/>
</field>
<field name="ratingvalue" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="ratingvalue"/>
</field>
</subDataset>
<queryString language="SQL">
<![CDATA[select 1 as one from customer limit 1]]>
</queryString>
<field name="one" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="one"/>
</field>
<summary>
<band height="414">
<componentElement>
<reportElement x="0" y="0" width="650" height="414" uuid="f8096db8-7106-4544-81f4-4158678dcaee">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="ColumnSpline">
<hc:chartSetting name="default">
<hc:chartProperty name="chart.zoomType">
<hc:propertyExpression><![CDATA["xy"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="colors">
<hc:propertyExpression><![CDATA[java.util.Arrays.asList("#7cb5ec","#434348","#FF0000","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1")]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.enabled">
<hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.href">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="plotOptions.series.allowPointSelect">
<hc:propertyExpression><![CDATA[Boolean.TRUE]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="plotOptions.series.dashStyle">
<hc:propertyExpression><![CDATA["Dash"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="title.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="legend.enabled_customSimpleMode" value="true"/>
<hc:chartProperty name="legend.enabled">
<hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="plotOptions.series.marker.symbol" value="diamond"/>
<hc:chartProperty name="plotOptions.series.marker.fillColor" value="#000000"/>
<hc:chartProperty name="plotOptions.column.groupPadding_customSimpleMode" value="true"/>
<hc:chartProperty name="plotOptions.column.pointPadding_customSimpleMode" value="true"/>
<hc:chartProperty name="plotOptions.column.pointPadding">
<hc:propertyExpression><![CDATA[0]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="plotOptions.column.pointInterval_customSimpleMode" value="true"/>
<hc:chartProperty name="plotOptions.series.marker.radius">
<hc:propertyExpression><![CDATA[8]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="xAxis.labels.useHTML_customSimpleMode" value="true"/>
<hc:chartProperty name="yAxis.labels.enabled_customSimpleMode" value="true"/>
<hc:chartProperty name="plotOptions.column.dataLabels.enabled_customSimpleMode" value="true"/>
<hc:chartProperty name="yAxis.labels.enabled">
<hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="xAxis.labels.step" value="1"/>
<hc:chartProperty name="xAxis.labels.style.textOverflow" value="wrap"/>
</hc:chartSetting>
<hc:chartSetting name="yAxis">
<hc:chartProperty name="_jrAxisIndex">
<hc:propertyExpression><![CDATA[1]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="id">
<hc:propertyExpression><![CDATA["id1"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="labels.style.fontSize" value="0"/>
<hc:chartProperty name="linkedTo">
<hc:propertyExpression><![CDATA[0]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="max" value="3"/>
<hc:chartProperty name="min">
<hc:propertyExpression><![CDATA[0]]></hc:propertyExpression>
</hc:chartProperty>
</hc:chartSetting>
<hc:chartSetting name="yAxis">
<hc:chartProperty name="_jrAxisIndex" value="0"/>
<hc:chartProperty name="id">
<hc:propertyExpression><![CDATA["id0"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="max" value="3"/>
<hc:chartProperty name="min">
<hc:propertyExpression><![CDATA[0]]></hc:propertyExpression>
</hc:chartProperty>
</hc:chartSetting>
<multiAxisData>
<multiAxisDataset>
<dataset>
<datasetRun subDataset="Dataset1" uuid="aa88620b-9675-468d-b14d-e460a4523487"/>
</dataset>
</multiAxisDataset>
<dataAxis axis="Rows">
<axisLevel name="Category">
<labelExpression><![CDATA["Level Label expression"]]></labelExpression>
<axisLevelBucket order="None" class="java.lang.String">
<bucketExpression><![CDATA[$F{category}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<dataAxis axis="Columns">
<axisLevel name="Series">
<labelExpression><![CDATA[]]></labelExpression>
<axisLevelBucket order="None" class="java.lang.Comparable">
<bucketExpression><![CDATA[$F{series}]]></bucketExpression>
<bucketProperty name="color"><![CDATA[$F{series}.equals("Rating1") ? "#c00000" : ($F{series}.equals("Rating2")?"#a5a5a5":($F{series}.equals("Rating3")?"#ffc000":($F{series}.equals("Rating4")?"#4472c4":"#ffffff")))]]></bucketProperty>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<multiAxisMeasure name="Measure1" class="java.math.BigDecimal" calculation="Nothing">
<labelExpression><![CDATA[""]]></labelExpression>
<valueExpression><![CDATA[$F{ratingvalue}]]></valueExpression>
</multiAxisMeasure>
<multiAxisMeasure name="Measure2" class="java.math.BigDecimal" calculation="Nothing">
<labelExpression><![CDATA[""]]></labelExpression>
<valueExpression><![CDATA[$F{series}.equals("Rating5")?$F{ratingvalue}:null]]></valueExpression>
</multiAxisMeasure>
</multiAxisData>
<hc:series name="Measure1">
<hc:contributor name="SeriesProperty">
<hc:contributorProperty name="yAxis" valueType="Constant" value="id0"/>
</hc:contributor>
<hc:contributor name="SeriesItemProperty">
<hc:contributorProperty name="color" valueType="Bucket" value="Series.color"/>
</hc:contributor>
</hc:series>
<hc:series name="Measure2">
<hc:contributor name="SeriesProperty">
<hc:contributorProperty name="yAxis" valueType="Constant" value="id1"/>
</hc:contributor>
</hc:series>
</hc:chart>
</componentElement>
</band>
</summary>
</jasperReport>


Tip ; How to wrap X-axis long labels for a column chart in Jaspersoft design studio reports

$
0
0
Give below advanced property for the column vizz.

xAxis.labels.style.textOverflow=wrap



This property may require in combination with above ( not tested, if above doesn't work this should be given)


Sample output: 


No sub report elements data displayed in report when calling the sub report from parent report Title band in jaspersoft design studio

$
0
0
I'd a report having 15 sub reports. Out of these 15, some were having textual design and some of them needed to connect to database and display certain data using elements such as table component or an html-5 chart.

I'd started keeping/calling all the sub reports in parent reports Title band. When the report is  exported word/pdf file from server, I could see the data has not displayed for the reports having data consuming elements.

If the same sub report published as an individual entity to the server it worked but that's not an option here because this report was one of the sub reports for parent.

Tried "when no data found" property and elements position type properties but non of them worked.

Randomly, added "summary" band to the master/parent report and tried calling the sub report from this band , it worked, i.e., data has displayed for the elements from sub report when ran the master/parent report.

No idea or clue on exact reason for why data is not displayed when keeping the sub report in master/parent report, however, summary solved it.

As a best practice, I would recommend to keep sub reports in summary band instead any other report bands.

Jaspersoft reports server valid login and invalid login automation tutorial using Java-Selenium-Cucumber

$
0
0
Hi ,

This is an introductory article on automating the Jaspersoft reports server user activities. In this tutorial, you would learn how to effectively implement cucumber framework with java selenium for Jaspersoft server.

NOTE : 
1) Assuming, the reader should already have basic knowledge on all the software's or technologies mentioned below.

Software's used: 
1) Eclipse - Version: 2.3.0.v20191210-0610, Build id: I20191210-0610
2) Java 1.8
3) Maven build tool (default comes with Eclipse)
4) Cucumber 1.2.5
5) Cucumber Junit 1.2.5
6) Junit 4.12
7) Log4j 1.2.17
8) Google Chrome Browser : Version 80.0.3987.132 (Official Build) (64-bit)
9) Jaspersoft 7.5 Community Server

Automation flow architecture: 
TBD

How to catch certain code in this post ? 
Please download the source code project zip using below link and import it into your latest eclipse environment then play around.

Note that you may have to download and point to correct chromedriver.exe driver. This demonstration is used chrome driver 80 versioned driver.

Download Jaspersoft Automation Artifacts (Eclipse Project)
Click me

Video tutorial : Execution flow of the project
TBD

Steps: 
1) Creating a new Maven project

       File -> New -> Project -> Maven -> Maven Project
         (Jaspersoft Automation is the project  name)

2) Addlog4j library to the project build path.
     
3) Ensure installed JRE points to locally installed jdk as shown in below image. 
    i.e., C:\Program Files\Java\jdk1.8.0_181


4)  Thefinal project folder structure is as follows.

5) pom.xml

This will download and install the required libraries for the project. 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>SMAPI_UI_POC</groupId>
  <artifactId>SMAPI_UI_POC</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>SMAPI_UI_POC</name>
  <description>SMAPI_UI_POC</description>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>

  <!--  cucumber-java -->
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.5</version>
</dependency>

  <!--  cucumber-junit -->
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.2.5</version>
</dependency>
<!--
<dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>3.0.2</version>
        <scope>test</scope>
    </dependency>
-->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
</dependency>
  </dependencies>

 <build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

6) configuration.properties

Read values from properties file 

chrome_driver_path=D:\\chromedriver_80\\chromedriver.exe
jaspersoft_server_url=http://localhost:8080/jasperserver
user_id=jasperadmin
password=jasperadmin

7) 001_LoginJaspersoftServer.feature 

Cucumber feature file with valid and invalid login scenarios using Scenario Outline concept.
This code of language is called as Gherkin 

#Author: sadakar.pochampalli
# https://docs.katalon.com/katalon-studio/docs/cucumber-features-file.html#maintain-features-file
# https://riptutorial.com/cucumber/example/28790/scenario-outline
#https://www.tutorialspoint.com/cucumber/cucumber_scenario_outline.htm
@Login
Feature: Login feature

  As a admin user, I want to login to Jaspersoft Server so that
  I can run the reports, dashboards, create ad-hoc reports and etc.

  @ValidLogin
  Scenario Outline: Login with valid credentials
    Given Chrome browser and Jaspersoft login page
    When I enter User Id as "<UserId>" and Password as "<Password>"
    And I click on Login button
    Then I should be able to login successfully

    Examples:
      | UserId      | Password    |
      | jasperadmin | jasperadmin |
      | joeuser     | joeuser     |

  @InvalidLogin
  Scenario Outline: Login with Invalid credentials
    Given Chrome browser and Jaspersoft login page
    When I enter User Id as "<UserId>" and Password as "<Password>"
    And I click on Login button
    Then I should NOT be able to login successfully

    Examples:
      | UserId  | Password    |
      | baduser | jasperadmin |
      | joeuser | badpassword |
      | baduser | badpassword |

8) log4j.properties

DEBUG, ERROR, INFO logs displayed in file at : D:\\jasper_selenium\\jasper_selenium.logs

# Root logger option
log4j.rootLogger=DEBUG,stdout,dest1,ERROR,INFO

# Direct log messages to a log file
log4j.appender.dest1=org.apache.log4j.RollingFileAppender
log4j.appender.dest1.File=D:\\jasper_selenium\\jasper_selenium.logs
log4j.appender.dest1.MaxFileSize=10MB
log4j.appender.dest1.MaxBackupIndex=10
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.dest1.Append=false

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

#ERROR
log4j.appender.ERROR=org.apache.log4j.RollingFileAppender
log4j.appender.ERROR.layout=org.apache.log4j.PatternLayout
log4j.appender.ERROR.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
#log4j.appender.ERROR.File=D:\\smapiui_logs\\smapi_ui.logs

#INFO
log4j.appender.INFO=org.apache.log4j.RollingFileAppender
log4j.appender.INFO.layout=org.apache.log4j.PatternLayout
log4j.appender.INFO.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
#log4j.appender.INFO.File=D:\\smapiui_logs\\smapi_ui.logs

9) Hooks.java - This class displays each scenario name with it's status. 

package com.sadakar.cucumber.common;
import com.sadakar.resource.utilities.Log;
import cucumber.api.Scenario;
import cucumber.api.java.After;
import cucumber.api.java.Before;

public class Hooks {
@Before(order=0)
public void before(Scenario scenario) {
    System.out.println("------------------------------");
    Log.info("------------------------------");
    Log.info("Scenario: '" + scenario.getName() );
    Log.info("******************************");
    System.out.println("Starting - " + scenario.getName());
    System.out.println("------------------------------");
}
@After(order=0)
public void after(Scenario scenario) {
    System.out.println("------------------------------");
    Log.info("Scenario: '" + scenario.getName() + "' has status " + scenario.getStatus());
    Log.info("******************************");
    Log.info("------------------------------");
    System.out.println(scenario.getName() + " Status - " + scenario.getStatus());
    System.out.println("------------------------------");
}
}

10) CucumberRunner.java

In this class, give path for the features, glue code, which scenarios to test/run and cucumber plugins such as reports in various formats

package com.sadakar.cucumber.runner;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions
(
features="classpath:features",
tags="@ValidLogin,@InvalidLogin",
glue={"com.sadakar.cucumber.stepdefinitions/","com.sadakar.cucumber.common"},
plugin = { "pretty", "json:target/cucumber-reports/Cucumber.json",
"junit:target/cucumber-reports/Cucumber.xml",
"html:target/cucumber-reports"},
monochrome = true
)
public class CucumberRunner {

}

11) LoginToJaspersoft.java

In this class define the step definitions for the scenarios. This code is called glue code. Wherever required, add the wait, sleep statements based on the logon speed of your jaspersoft server. 

package com.sadakar.cucumber.stepdefinitions;

import com.sadakar.resource.utilities.Log;
import com.sadakar.selenium.common.BasePage;
import com.sadakar.selenium.common.CommonFunctions;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;

public class LoginToJaspersoft extends BasePage{
CommonFunctions cf = new CommonFunctions();
@Given("^Chrome browser and Jaspersoft login page$")
public void chrome_browser_and_Jaspersoft_login_page() throws Throwable {
try {   
cf.initDriver();
cf.maximizeDriver();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
cf.getJapsersoftURL();
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
catch(Exception e) {
Log.error("failed to open the Japsersoft URL or Login page"+e);
Assert.fail("failed to open the Japsersoft URL or Login page"+e);
}
}

@When("^I enter User Id as \"([^\"]*)\" and Password as \"([^\"]*)\"$")
public void i_enter_User_Id_as_and_Password_as(String arg1, String arg2) throws Throwable {
  Log.debug("Enter User Id");
  driver.findElement(By.xpath("//*[@id='j_username']")).sendKeys(arg1+Keys.TAB);
  Log.debug("Enter tab");
  Log.debug("Enter Password");
      driver.findElement(By.xpath("//*[@id='j_password_pseudo']")).sendKeys(arg2+Keys.TAB);
      Log.debug("Enter tab");
}
@And("^I click on Login button$")
public void i_click_on_Login_button() throws Throwable {
Log.debug("Click Login button");
      driver.findElement(By.xpath("//*[@id='submitButton']/span[1]")).click();  
      Thread.sleep(5000);
}

@Then("^I should be able to login successfully$")
public void i_should_be_able_to_login_successfully() throws Throwable {
if(driver.getCurrentUrl().equalsIgnoreCase(
      "http://localhost:8080/jasperserver/flow.html?_flowId=searchFlow")){
         Log.debug("Login Successfull");
      } else { 
         Log.debug("Login NOT Success full");
         Assert.fail("Login NOT Success full");
      } 
driver.close(); 
driver.quit();
}
@Then("^I should NOT be able to login successfully$")
public void i_should_NOT_be_able_to_login_successfully() throws Throwable {
if(driver.getCurrentUrl().equalsIgnoreCase(
      "http://localhost:8080/jasperserver/login.html?error=1")){
         Log.debug("Invalid Login Successfull");
      } else { 
         Log.debug("Invalid Login NOT Success full");
         Assert.fail("Invalid Login NOT Success full");
      } 
driver.close(); 
driver.quit();
}
}

12) Log.java

package com.sadakar.resource.utilities;
import org.apache.log4j.Logger;
public class Log {

public static Logger log= Logger.getLogger(Log.class.getSimpleName());
//Logger log2 = Logger.getLogger("devpinoyLogger");

/**
* To print Log for the start test case
* @param startTestCaseMessage
*/
public static void startTestCase(String startTestScenario ) {
log.info("********************* " + "S_T_A_R_T" + " *********************");
log.info("********************* " + startTestScenario + " *********************");
}

/**
* This is to print Log for the ending of the test case
* @param endTestCaseMessage
*/
public static void endTestCase(String endTestScenario) {
log.info("********************* " + "-E---N---D-" + " *********************");
log.info("********************* " + endTestScenario + " *********************");
}

public static void info(String infoMessage) {
log.info(infoMessage);
}

public static void warn(String warnMessage) {
log.warn(warnMessage);
}

public static void error(String errorMessage) {
log.error(errorMessage);
}

public static void fatal(String fatalMessage) {
log.fatal(fatalMessage);
}

public static void debug(String debugMessage) {
log.debug(debugMessage);
}

}

13) PropertyManager.java

package com.sadakar.resource.utilities;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
public class PropertyManager {
private static PropertyManager instance;
    private static final Object lock = new Object();
    private static String propertyFilePath=System.getProperty("user.dir") + "\\configuration.properties";    
    private static String jaspersoft_server_url;
    private static String chrome_driver_path;
    private static String user_id;
    private static String password;
    
    //Create a Singleton instance. We need only one instance of Property Manager.
    public static PropertyManager getInstance () {
        if (instance == null) {
            synchronized (lock) {
                instance = new PropertyManager();
                instance.loadData();
            }
        }
        return instance;
    }
    //Get all configuration data and assign to related fields.
    private void loadData() {
        //Declare a properties object
        Properties prop = new Properties();
        //Read configuration.properties file
        try {
            prop.load(new FileInputStream(propertyFilePath));
            //prop.load(this.getClass().getClassLoader().getResourceAsStream("configuration.properties"));
        } catch (IOException e) {
            System.out.println("Configuration properties file cannot be found");
        }
        //Get properties from configuration.properties
        jaspersoft_server_url = prop.getProperty("jaspersoft_server_url");
        chrome_driver_path=prop.getProperty("chrome_driver_path");
        user_id=prop.getProperty("user_id");
        password=prop.getProperty("password");

    }
    public String getAppMangtURL () {
      return jaspersoft_server_url;
    }
    public String getChormeDriverPath () {
        return chrome_driver_path;
      }
    
    public String getUserId () {
        return user_id;
      }
      public String getPassword () {
          return password;
        }
}

14) Basepage.java

package com.sadakar.selenium.common;
import org.openqa.selenium.WebDriver;

public class BasePage {
public  static WebDriver driver;
public static void main(String args[]){
}

}

15) CommonFunctions.java

package com.sadakar.selenium.common;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import com.sadakar.resource.utilities.Log;
import com.sadakar.resource.utilities.PropertyManager;

import org.openqa.selenium.PageLoadStrategy;
public class CommonFunctions extends BasePage{
String chromeDriverPath=PropertyManager.getInstance().getChormeDriverPath();
String appMangtURL = PropertyManager.getInstance().getAppMangtURL();

public void initDriver() {
Log.debug("finding chrome driver path");
System.setProperty("webdriver.chrome.driver",chromeDriverPath);
Log.debug("Chrome driver path found");
Log.debug("Initiate Chrome driver");
ChromeOptions options = new ChromeOptions();
        //options.addArguments("--headless");
        options.addArguments("--disable-gpu");
        options.setPageLoadStrategy(PageLoadStrategy.NONE);
        options.addArguments("--allow-insecure-localhost");
        options.addArguments("--allow-running-insecure-content");
        options.addArguments("--ignore-certificate-errors");
        options.addArguments("--no-sandbox");
        options.addArguments("--window-size=1280,1000");
        options.setCapability("acceptSslCerts", true);
        options.setCapability("acceptInsecureCerts", true);
        
driver = new ChromeDriver(options);
Log.debug("Chrome driver is being initiated");
}
public void maximizeDriver() {
Log.debug("Maximize Chrome Browser");
driver.manage().window().maximize();
Log.debug("Chrome Browser maximized");
}
public void getJapsersoftURL() {
Log.debug("Authenticating to Jaspersoft Reports Server");
//System.out.println("App magt URL="+appMangtURL);
//driver.get("http://management.myabilitynetwork.lab/");
        driver.get(appMangtURL);
        Log.debug("Enter User ID and Password");
}
public void closeDriver() {
Log.debug("Closing driver: Closing browser");
driver.close();
Log.debug("Driver is closed: Closed browser");
}
public void quitDriver() {
Log.debug("Closing driver session");
driver.quit();
Log.debug("Driver session is closed");
}

}

16) Cucumber reports




17) jasper_selenium.logs

2020-03-13 19:22:57 INFO  Log:30 - ------------------------------
2020-03-13 19:22:57 INFO  Log:30 - Scenario: 'Login with valid credentials
2020-03-13 19:22:57 INFO  Log:30 - ******************************
2020-03-13 19:22:57 DEBUG Log:46 - finding chrome driver path
2020-03-13 19:22:57 DEBUG Log:46 - Chrome driver path found
2020-03-13 19:22:57 DEBUG Log:46 - Initiate Chrome driver
2020-03-13 19:23:07 DEBUG Log:46 - Chrome driver is being initiated
2020-03-13 19:23:07 DEBUG Log:46 - Maximize Chrome Browser
2020-03-13 19:23:07 DEBUG Log:46 - Chrome Browser maximized
2020-03-13 19:23:07 DEBUG Log:46 - Authenticating to Jaspersoft Reports Server
2020-03-13 19:23:07 DEBUG Log:46 - Enter User ID and Password
2020-03-13 19:23:07 DEBUG Log:46 - Enter User Id
2020-03-13 19:23:08 DEBUG Log:46 - Enter tab
2020-03-13 19:23:08 DEBUG Log:46 - Enter Password
2020-03-13 19:23:08 DEBUG Log:46 - Enter tab
2020-03-13 19:23:08 DEBUG Log:46 - Click Login button
2020-03-13 19:23:14 DEBUG Log:46 - Login Successfull
2020-03-13 19:23:15 INFO  Log:30 - Scenario: 'Login with valid credentials' has status passed
2020-03-13 19:23:15 INFO  Log:30 - ******************************
2020-03-13 19:23:15 INFO  Log:30 - ------------------------------
2020-03-13 19:23:15 INFO  Log:30 - ------------------------------
2020-03-13 19:23:15 INFO  Log:30 - Scenario: 'Login with valid credentials
2020-03-13 19:23:15 INFO  Log:30 - ******************************
2020-03-13 19:23:15 DEBUG Log:46 - finding chrome driver path
2020-03-13 19:23:15 DEBUG Log:46 - Chrome driver path found
2020-03-13 19:23:15 DEBUG Log:46 - Initiate Chrome driver
2020-03-13 19:23:24 DEBUG Log:46 - Chrome driver is being initiated
2020-03-13 19:23:24 DEBUG Log:46 - Maximize Chrome Browser
2020-03-13 19:23:24 DEBUG Log:46 - Chrome Browser maximized
2020-03-13 19:23:24 DEBUG Log:46 - Authenticating to Jaspersoft Reports Server
2020-03-13 19:23:24 DEBUG Log:46 - Enter User ID and Password
2020-03-13 19:23:24 DEBUG Log:46 - Enter User Id
2020-03-13 19:23:25 DEBUG Log:46 - Enter tab
2020-03-13 19:23:25 DEBUG Log:46 - Enter Password
2020-03-13 19:23:25 DEBUG Log:46 - Enter tab
2020-03-13 19:23:25 DEBUG Log:46 - Click Login button
2020-03-13 19:23:30 DEBUG Log:46 - Login Successfull
2020-03-13 19:23:31 INFO  Log:30 - Scenario: 'Login with valid credentials' has status passed
2020-03-13 19:23:31 INFO  Log:30 - ******************************
2020-03-13 19:23:31 INFO  Log:30 - ------------------------------
2020-03-13 19:23:31 INFO  Log:30 - ------------------------------
2020-03-13 19:23:31 INFO  Log:30 - Scenario: 'Login with Invalid credentials
2020-03-13 19:23:31 INFO  Log:30 - ******************************
2020-03-13 19:23:31 DEBUG Log:46 - finding chrome driver path
2020-03-13 19:23:31 DEBUG Log:46 - Chrome driver path found
2020-03-13 19:23:31 DEBUG Log:46 - Initiate Chrome driver
2020-03-13 19:23:40 DEBUG Log:46 - Chrome driver is being initiated
2020-03-13 19:23:40 DEBUG Log:46 - Maximize Chrome Browser
2020-03-13 19:23:41 DEBUG Log:46 - Chrome Browser maximized
2020-03-13 19:23:41 DEBUG Log:46 - Authenticating to Jaspersoft Reports Server
2020-03-13 19:23:41 DEBUG Log:46 - Enter User ID and Password
2020-03-13 19:23:41 DEBUG Log:46 - Enter User Id
2020-03-13 19:23:42 DEBUG Log:46 - Enter tab
2020-03-13 19:23:42 DEBUG Log:46 - Enter Password
2020-03-13 19:23:42 DEBUG Log:46 - Enter tab
2020-03-13 19:23:42 DEBUG Log:46 - Click Login button
2020-03-13 19:23:47 DEBUG Log:46 - Invalid Login Successfull
2020-03-13 19:23:48 INFO  Log:30 - Scenario: 'Login with Invalid credentials' has status passed
2020-03-13 19:23:48 INFO  Log:30 - ******************************
2020-03-13 19:23:48 INFO  Log:30 - ------------------------------
2020-03-13 19:23:48 INFO  Log:30 - ------------------------------
2020-03-13 19:23:48 INFO  Log:30 - Scenario: 'Login with Invalid credentials
2020-03-13 19:23:48 INFO  Log:30 - ******************************
2020-03-13 19:23:48 DEBUG Log:46 - finding chrome driver path
2020-03-13 19:23:48 DEBUG Log:46 - Chrome driver path found
2020-03-13 19:23:48 DEBUG Log:46 - Initiate Chrome driver
2020-03-13 19:23:57 DEBUG Log:46 - Chrome driver is being initiated
2020-03-13 19:23:57 DEBUG Log:46 - Maximize Chrome Browser
2020-03-13 19:23:57 DEBUG Log:46 - Chrome Browser maximized
2020-03-13 19:23:57 DEBUG Log:46 - Authenticating to Jaspersoft Reports Server
2020-03-13 19:23:57 DEBUG Log:46 - Enter User ID and Password
2020-03-13 19:23:57 DEBUG Log:46 - Enter User Id
2020-03-13 19:23:58 DEBUG Log:46 - Enter tab
2020-03-13 19:23:58 DEBUG Log:46 - Enter Password
2020-03-13 19:23:58 DEBUG Log:46 - Enter tab
2020-03-13 19:23:58 DEBUG Log:46 - Click Login button
2020-03-13 19:24:03 DEBUG Log:46 - Invalid Login Successfull
2020-03-13 19:24:04 INFO  Log:30 - Scenario: 'Login with Invalid credentials' has status passed
2020-03-13 19:24:04 INFO  Log:30 - ******************************
2020-03-13 19:24:04 INFO  Log:30 - ------------------------------
2020-03-13 19:24:04 INFO  Log:30 - ------------------------------
2020-03-13 19:24:04 INFO  Log:30 - Scenario: 'Login with Invalid credentials
2020-03-13 19:24:04 INFO  Log:30 - ******************************
2020-03-13 19:24:04 DEBUG Log:46 - finding chrome driver path
2020-03-13 19:24:04 DEBUG Log:46 - Chrome driver path found
2020-03-13 19:24:04 DEBUG Log:46 - Initiate Chrome driver
2020-03-13 19:24:14 DEBUG Log:46 - Chrome driver is being initiated
2020-03-13 19:24:14 DEBUG Log:46 - Maximize Chrome Browser
2020-03-13 19:24:14 DEBUG Log:46 - Chrome Browser maximized
2020-03-13 19:24:14 DEBUG Log:46 - Authenticating to Jaspersoft Reports Server
2020-03-13 19:24:14 DEBUG Log:46 - Enter User ID and Password
2020-03-13 19:24:14 DEBUG Log:46 - Enter User Id
2020-03-13 19:24:15 DEBUG Log:46 - Enter tab
2020-03-13 19:24:15 DEBUG Log:46 - Enter Password
2020-03-13 19:24:15 DEBUG Log:46 - Enter tab
2020-03-13 19:24:15 DEBUG Log:46 - Click Login button
2020-03-13 19:24:20 DEBUG Log:46 - Invalid Login Successfull
2020-03-13 19:24:21 INFO  Log:30 - Scenario: 'Login with Invalid credentials' has status passed
2020-03-13 19:24:21 INFO  Log:30 - ******************************
2020-03-13 19:24:21 INFO  Log:30 - ------------------------------

Handling internet explorer windows based authentication to a website using AutoIT script in java-cucumber-selenium automation

$
0
0
Hi,

In this post, you will see tips on how to authenticate a website that is based on windows authentication. 
Reader is assumed to have some prior fundamental knowledge on the java-selenium-cucumber framework/setup. 

NOTE: 
This post is not written to give step-by-step procedure instead written to give direct inputs on specific areas. 

Sample cucumber feature file and scenario: 

@feature_login
Feature: Launch internet browser and login with valid credentials
  This is a windows based authentication for sadakar.selenium.com site using internet browser.

  @senario_loginsadakar.selenium.com
  Scenario: Login to sadakar.selenium.com with internet explorer windows based authentication
    When I open internet explorer browser
    Then I login with username and password and navigate to sadakar.selenium.com


Problem statement : 
When you try to open sadakar.selenium.com and if the website is configured for windows based authentication as shown in below image - how do you navigate to the site using java-selenium code ? 

Click on the image to get best view of the content: 
Solution : 
1) Install latest Auto IT tool ( download : https://www.autoitscript.com/site/autoit/downloads/ )
2) Then : 
        a) Open the website with its security pop-up for windows based authentication 
        b) Open the AutoIt tool on top of the the website's windows security pop-up. 
3) Hold on "Finder Tool" on AutoIT and drag that on to the security pop-up window. 
4) Note down "Title" and "Class" in the AutoIt tool. 

Click on the image to get best view of the content: 


5) Now, in Notepad++ file write below code and save it as "autoit_ie.au3"

$sUsername = "SADA001\administrator"
$sPassword = "SADAPassWord@001"
$sTitle = WinGetTitle("Windows Security")
Sleep(1000)
    If $sTitle = "Windows Security" or WinWaitActive("[CLASS:Credential Dialog Xaml Host]") or WinWaitActive("Windows Security") or WinWaitActive("iexplore.exe") or WinWaitActive("Connecting to sadakar.selenium.com")Then
        Send($sUsername)
        Send("{TAB}")
        Send($sPassword,1)
        Send("{TAB}")
        Send("{ENTER}")
    EndIf

6) Right click on the saved file and compile it (just compile) and you would see "autoit_ie.exe" generated in the folder where you saved your au3 file. 

NOTE : 
if you try open this .exe, you would see some encrypted data that will not be readable. 

7) How to call the generated autoit_ie.exe file in java-selenium. 

  public void getCredentialsFromAutoITExe() {
try {
Log.debug("Reading Username and Password from IE AutoIT exe file");
                                 System.out.println("Reading Username and Password from IE AutoIT exe file");
Runtime.getRuntime().exec("D:\\autoit_ie.exe");
Log.debug("Read Username and Password from AutoIT exe file");
}
 
}catch(Exception e) {
Assert.fail("failed to Read Username and Password from AutoIT exe file");
System.out.println("failed to read credentials from AutoIT exe file"+""+e);
}
}

 public void getAppManagementURL() {

Log.debug("Authenticating to sadakar.selenium.com URL");
 driver.get("http://sadakar.selenium.com/");
                  Log.debug("Authenticated to Application URL and opened the site                             
                       http://sadakar.selenium.com/");
}

7) When you run your project (in my case its a maven-java-selenium-junit-cucumber) the pop-up should read the username and password from the auto_it.exe file and fill the corresponding values as shown in below image.

NOTE : 
Runtime.getRuntime().exec("auto it exe file path") should be called before driver.get("URL")


Thank you, for stopping by and I hope it helps someone in the community. 

Drill down from Parent report to Child report in Jaspersoft Studio reports - Pie chart to tabular data drill down

$
0
0
Software : 
----------------
1) J. Studio 7.2 pro
2) Jasperreports server 7.5 Enterprise


Requirement :
-----------------
Drill down to customer detailed report from customer total number of cars by occupation
i.e., Pie graph to tabular data.

Watch 10 min video tutorial: 


Click on image to get best view of content: 

SQL query :
--------------
Parent report :
-----------------
select occupation, sum(num_cars_owned) cars  from customer
group by occupation
order by occupation

Child report:
-----------------
select * from customer where occupation= $P{paramOccupation}

Steps :
-----------
1. Design Parent report with Pie graph.
2. Design Child report with tabular data having "paramOccupation" parameter.
3. Publish Parent report and unit test the output.
4. Publish Child report and unit test the output with various input values for the parameter.

Hyperlinking/Drill down to the Child report from Parent report
----------------------------------------------------------------
1. Edit the Pie vizz. of Parent report.

2. For Categories Levels, create "Bucket Properties" i.e., paramOccupation=$F{occupation}

3. For Measures, click on "Edit Hyperlink" -> check "Use Hyperlink"

4. Click on _report[SeriesItemHyperlink] -> Use Constant value i.e.,_report=/Praveen/Child

5. Clcik on Add to link the parameter
 
   PropertyName=paramOccupation
   UseBucketValue=Level1.paramOccupation

Click on image to get best view of content:  


Post linking steps:
----------------------
1. Re-publish the Parent report.
2. In the server, edit the child report --> navigate to "Controls and Resources"
3. Change : Display Mode= In Page and un-check "Always prompt"

NOTE:
---------
1. In the Child report JRXML, for the parameter, check the "Is For Prompting" property.




Automating JasperReports Server Login Page using java-selenium-cucumber | Video tutorial on how to run cucumber project from jar file ?

$
0
0
Hi,

In this post, I'd like to share my experience on automating jaspersoft login page using valid (not invalid) credentials using cucumber frame work.

The core of this post is how to generate jar file to run the cucumber project/features from command prompt. You can watch the below  video tutorial for the whole project flow, coding inputs, etc. and I hope this will be helpful for someone in the community.

Watch this ~15 min video tutorial for the cucumber execution flow and for some coding inputs




Below are the steps for core part that is how to generate jar and run cucumber project from jar file.

1) In the pom.xml ensure to provide plugin details for jar and mainClass.
    This is used to generate the manifest file where the project execution starts when execute the jar from command prompt.

2) Write a main method and pass the cucumber options as String to the Main class.

3) Run the project as Maven build by providing : clean package shade:shade 

4) Note down the path of the generated jar

5) Open command prompt and navigate to the path run this command
          java -jar <GeneratedJarFile>


pom.xml plugin snippet for jar:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
      <archive>
          <manifest>
             <addClasspath>true</addClasspath>
                <mainClass>com.sadakar.selenium.common.BasePage</mainClass>
          </manifest>
      </archive>
                </configuration>

</plugin>

calling main method with cucumber options as input
package com.sadakar.selenium.common;
import org.openqa.selenium.WebDriver;
public class BasePage {
public  static WebDriver driver;
public static void main(String args[]) throws Throwable{
try {
cucumber.api.cli.Main.main(
new String[]{
"classpath:features",
"-t","@ValidLogin",
"-g", "com.sadakar.cucumber.stepdefinitions/", 
"-g","com.sadakar.cucumber.common",
"-p","pretty", 
"-p","json:target/cucumber-reports/Cucumber.json",
"-p", "html:target/cucumber-reports",

}
             ); 
}
catch(Exception e) {
System.out.println("Main method exception");
}

}

}

Build the jar file : clean package shade:shade


Navigate to the target folder where jar is generated and running it.
C:\Users\sadakar\eclipse-workspace\Jaspersoft Automation\target>java -jar Jaspersoft_Automation-0.0.1-SNAPSHOT.jar

Click on the image to get the best view of the content:


Sample output:

Tip : Set relative path for selenium chrome web driver

$
0
0
In this post, you will see java snippet inputs for  calling chromedriver.exe file eclipse project relative path.

1) Create folder "drivers" for the project.

2) Upload the chromedriver.exe file as shown in below image. (chromedriver_80 another folder created under drivers folder)

3) Right click on the "chromedriver.exe" and make note of the path
     for example : /Jaspersoft Automation/drivers/chromedriver_80/chromedriver.exe

4) Define a key-value pair for the driver path in configuration.properties file
     chrome_driver_path=\\drivers\\chromedriver_80\\chromedriver.exe

5) While setting System property for driver, give the relative path 
System.setProperty("webdriver.chrome.driver",path+chromeDriverPath);

Run the project using Junit and observe that the driver instantiated from the relative path provided.

Detailed code snippets follows....



configuration.properties 

# Give this relative path of the driver uploaded for "drivers" folder in eclipse project.
chrome_driver_path=\\drivers\\chromedriver_80\\chromedriver.exe

Code snippet in CommonFunctions.java file i.e., instantiating the chrome driver

public void initDriver() {

String chromeDriverPath=PropertyManager.getInstance().getChormeDriverPath();

String path = System.getProperty("user.dir");
System.out.println(path); 

System.setProperty("webdriver.chrome.driver",path+chromeDriverPath);

}

getChromeDriverPath() is the method defined in PropertyManager.java

public class PropertyManager {

     private static PropertyManager instance;
    private static final Object lock = new Object();
    //private static String propertyFilePath=System.getProperty("user.dir") + "\\configuration.properties"; 
    private static String app_mangt_url;
    private static String auth_uname_pwd_autoit_path;
   private static String chrome_driver_path;
    private static String browser_type;
    private static String ie_driver_path;
    private static String auth_uname_pwd_autoit_path_ie;
 
    //Create a Singleton instance. We need only one instance of Property Manager.
    public static PropertyManager getInstance () {
        if (instance == null) {
            synchronized (lock) {
                instance = new PropertyManager();
                instance.loadData();
            }
        }
        return instance;
    }

    //Get all configuration data and assign to related fields.
    private void loadData() {
        //Declare a properties object
        Properties prop = new Properties();

        //Read configuration.properties file
        try {
            //prop.load(new FileInputStream(propertyFilePath));
                               prop.load(this.getClass().getClassLoader().getResourceAsStream("configuration.properties"));
        } catch (IOException e) {
            System.out.println("Configuration properties file cannot be found");
        }

        //Get properties from configuration.properties
        app_mangt_url = prop.getProperty("app_mangt_url");
        auth_uname_pwd_autoit_path=prop.getProperty("auth_uname_pwd_autoit_path");
       chrome_driver_path=prop.getProperty("chrome_driver_path");
        browser_type=prop.getProperty("browser_type");
        ie_driver_path=prop.getProperty("ie_driver_path");
     
        auth_uname_pwd_autoit_path_ie=prop.getProperty("auth_uname_pwd_autoit_path_ie");

    }

    public String getAppMangtURL () {
      return app_mangt_url;
    }
    public String getAuthUnamePwdAutoIT () {
        return auth_uname_pwd_autoit_path;
      }
   public String getChormeDriverPath () {
        return chrome_driver_path;
      }
    public String getbrowserType () {
        return browser_type;
      }
    public String getIEDriverPath () {
        return ie_driver_path;
      }
    public String getAuthUnamePwdAutoITIE () {
        return auth_uname_pwd_autoit_path_ie;
      }

}

Hope this helps you.

Cheers.!

Drill with in the report in jasper reports

$
0
0
This is an extended tutorial of my post back in 2015, today, I needed to implement the same and struggled to get the old example working, so, thought of documenting it again with server export available for the community. 

https://jasper-bi-suite.blogspot.com/2015/01/tip-intercharts-drill-down-technique-in.html
Tip : Intra charts/components linking technique in Jasper reports : HTML5 charts inter linking with in report in Jasper Studio 6.x

Problem Statement : 
How to drill down with in the report ? How to get dynamic data displayed in a table component when performed click action on particular slices from Pie Chart ?

Pie : Number of cars by Occupation
Table : Details of customer by occupation





Solution :  
1) Create a parameter say : $P{paramOccupation} for main report and give default value
         In this example default value is given as "Manual"
2) Create a data set and create the same parameter and filter the query with this parameter.
3) Design Pie graph and table component.
4) For the Pie graph category create Bucket Property
        paramOccupation = $F{paramOccupation}
4) For the pie graph Hyperlink give _report = path of the same report from J.Server.
    and add parameter as shown in below image.
  i.e.,
(NOTE : Assuming the report is published already to the server)

_report="/Praveen/Drill_with_in_reports"                  
  paramOccupation=Level1.paramOccupation   (This is the Bucket property created for category)


5) Make sure the table component "Dateset" is added with Parameter
       i.e., In table component properties --> Parameters -->
         Add paramOccupation=${paramOccupation}

6) Re publish the report to Jasper Server and hide the paramOccupation parameter
         
Download the server zip file for live example :  Click Me
Import this zip to your jasper server and run "Drill with in report" report from "Praveen" folder


JRXML: 
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 7.2.0.final using JasperReports Library version 6.6.0  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Drill with in reports" pageWidth="1000" pageHeight="842" columnWidth="960" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4b0b908c-5907-4119-9d85-00671c2494af">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="ireport.jasperserver.url" value="http://localhost:8080/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.reportUnit" value="/Praveen/Drill_with_in_reports"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<property name="ireport.jasperserver.report.resource" value="/Praveen/Drill_with_in_reports_files/main_jrxml"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Dataset1-table" uuid="24749c25-55a5-49c2-be2d-f5dc1ec06acb">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<parameter name="paramOccupation" class="java.lang.String"/>
<queryString>
<![CDATA[select * from customer where occupation= $P{paramOccupation} limit 10]]>
</queryString>
<field name="customer_id" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="customer_id"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="account_num" class="java.lang.Long">
<property name="com.jaspersoft.studio.field.label" value="account_num"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="lname" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="lname"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="fname" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="fname"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="mi" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="mi"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="address1" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="address1"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="address2" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="address2"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="address3" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="address3"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="address4" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="address4"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="city" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="city"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="state_province" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="state_province"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="postal_code" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="postal_code"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="country" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="country"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="customer_region_id" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="customer_region_id"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="phone1" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="phone1"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="phone2" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="phone2"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="birthdate" class="java.sql.Date">
<property name="com.jaspersoft.studio.field.label" value="birthdate"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="marital_status" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="marital_status"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="yearly_income" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="yearly_income"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="gender" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="gender"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="total_children" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="total_children"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="num_children_at_home" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="num_children_at_home"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="education" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="education"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="date_accnt_opened" class="java.sql.Date">
<property name="com.jaspersoft.studio.field.label" value="date_accnt_opened"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="member_card" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="member_card"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="occupation" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="occupation"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="houseowner" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="houseowner"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="num_cars_owned" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="num_cars_owned"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="fullname" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="fullname"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
</subDataset>
<parameter name="paramOccupation" class="java.lang.String">
<defaultValueExpression><![CDATA["Manual"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select occupation, sum(num_cars_owned) cars  from customer
group by occupation
 order by occupation]]>
</queryString>
<field name="occupation" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="occupation"/>
<property name="com.jaspersoft.studio.field.tree.path" value="customer"/>
</field>
<field name="cars" class="java.lang.Long">
<property name="com.jaspersoft.studio.field.label" value="cars"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="420" splitType="Stretch">
<componentElement>
<reportElement x="0" y="80" width="400" height="340" uuid="07f8444d-5b85-4950-aefc-4e4b3f62c16c"/>
<hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="Pie">
<hc:chartSetting name="default">
<hc:chartProperty name="title.text" value=""/>
<hc:chartProperty name="credits.enabled" value="false"/>
<hc:chartProperty name="credits.href" value=""/>
<hc:chartProperty name="credits.text" value=""/>
<hc:chartProperty name="yAxis.title.text" value=""/>
<hc:chartProperty name="chart.zoomType" value="xy"/>
<hc:chartProperty name="plotOptions.pie.showInLegend" value="true"/>
</hc:chartSetting>
<multiAxisData>
<multiAxisDataset/>
<dataAxis axis="Rows">
<axisLevel name="Level1">
<labelExpression><![CDATA["Level Label expression"]]></labelExpression>
<axisLevelBucket class="java.lang.Comparable">
<bucketExpression><![CDATA[$F{occupation}]]></bucketExpression>
<labelExpression><![CDATA[]]></labelExpression>
<bucketProperty name="paramOccupation"><![CDATA[$F{occupation}]]></bucketProperty>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<dataAxis axis="Columns"/>
<multiAxisMeasure name="Measure1" class="java.lang.Number" calculation="Nothing">
<labelExpression><![CDATA["Cars"]]></labelExpression>
<valueExpression><![CDATA[$F{cars}]]></valueExpression>
</multiAxisMeasure>
</multiAxisData>
<hc:series name="Measure1">
<hc:contributor name="SeriesItemHyperlink">
<hc:contributorProperty name="hyperlinkTarget" valueType="Constant" value="Self"/>
<hc:contributorProperty name="hyperlinkType" valueType="Constant" value="ReportExecution"/>
<hc:contributorProperty name="_report" valueType="Expression">
<hc:valueExpression><![CDATA["/Praveen/Drill_with_in_reports"]]></hc:valueExpression>
</hc:contributorProperty>
<hc:contributorProperty name="paramOccupation" valueType="Bucket" value="Level1.paramOccupation"/>
</hc:contributor>
</hc:series>
</hc:chart>
</componentElement>
<componentElement>
<reportElement x="420" y="60" width="540" height="60" uuid="100a6fe4-7159-4de7-a8af-ec3abb357d30">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Dataset1-table" uuid="10d6d999-3da9-4530-b062-fe2fc3cd4330">
<datasetParameter name="paramOccupation">
<datasetParameterExpression><![CDATA[$P{paramOccupation}]]></datasetParameterExpression>
</datasetParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="110" uuid="6eabdd56-6307-4a16-b24d-0bd7f9d8af20">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="110" height="30" uuid="8a77e308-071d-4305-b50d-0a4c2469db0c"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[account_num]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="110" height="30" uuid="894b8b9c-47e8-4943-9ce9-1d5d9da3895d"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{account_num}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="130" uuid="bd701c03-37dd-4ac7-9d88-bbd6ad9e6ef3">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="130" height="30" uuid="e0a9941b-2b4e-473c-98bf-c1dc4039b841"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[occupation]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="130" height="30" uuid="8d464964-5455-4479-9ff3-30badb9dbc13"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{occupation}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="140" uuid="ec42ddc4-b560-400f-ae5c-2661a02e2607">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="140" height="30" uuid="81af8ec1-0046-4c1e-87dd-fdc7693678b9"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[country]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="140" height="30" uuid="bb5ab017-42ca-49cd-847a-94c55853cc52"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{country}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="160" uuid="313a65a4-3caa-494e-a6fb-502eb5030755">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="160" height="30" uuid="ceb0dd75-ca3f-4351-a343-93e4d33515f0"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[total_children]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="160" height="30" uuid="ef9155f3-1e33-405f-9b7f-861d02b5fd95"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{total_children}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
<textField>
<reportElement x="30" y="20" width="130" height="30" uuid="859c4814-f726-45ab-b928-07af80779061"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{paramOccupation}]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>

Export excel test data to executable jar file(bundle excel within jar) and read it from the jar for java-selenium-cucumber projects (OR) Read excel test data from the eclipse resources (OR) Read excel test data from the location where jar is generated

$
0
0
In this post, I'd like to share some fundamental coding techniques for the following questions. These techniques are useful when working on selenium based QA projects or generally in java based projects. It is pretty handy to play with excel read/write while working in tools, for instance Eclipse but what if the project needs a distribution to lab environments.

Problem statement : 
1) How to read excel test file/content data from eclipse project folder structure ?
2) How to bundle and read the excel test data file/content within the executable jar file ?
3) How to read the excel test data file from the location where jar is generated ?

Google search helped me to achieve the question-1, the latter ones are achieved through a java expert folk(thank you for the inputs and explanation). I'd like to keep it open for the community folks who are beginners with selenium frameworks.

Here we go.!
Maven based eclipse project structure:


Common code in all the 3 scenarios above: 

Read the excel data using getResourceAsSteam 

publicstatic InputStream getResource(String filename){
InputStream inputStream = ExcelUtils.class.getResourceAsStream(filename);
if(null== inputStream){
//fail("Resource not found: `" + filename + "`");
Log.error("Resource not found: `"+ filename +"`");
}
return inputStream;
}
1) How to read excel test file/content data from eclipse project folder structure ? 

This is useful to feed the forms with excel test data from the eclipse project.

a) Create a "data" folder in src/main/resources and
             add "Accounts_Test_Data_Automation.xlsx"  file.

b) Below piece of code does the trick.
fileName ="/data/"+ fileName;
ExcelFile = getResource(fileName);


2) How to bundle and read the excel test data file/content within the executable jar file ?

This piece of code does the trick of  bundling excel file into jar. Same as in question-1, look at the setExcelfile method.
//This code ships the excel file into the jar
ExcelFile = getResource("/data/"+fileName);
//Instead of above one case use blow direct project path for the excel file to be bundled
//ExelFile = getResource("/data/Accounts_Test_Data_Automation.xlsx");

pom.xml should be included with the maven-assembly-plugin

<plugin>
<!-- NOTE: We don't need a groupId specification because the group is
org.apache.maven.plugins ...which is assumed by default.
-->
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.sadakar.selenium.common.BasePage</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

Use below command while building the Maven project
clean compile assembly:single install

It will generated the jar file in .m2 repository. Extract of jar should contain the excel file within the "data" folder. While running the command use DtestEnv environment variable. By passing this variable from the command prompt, the code checks for the logic(above jar code) written to read the excel path.

String testEnv = System.getProperty("testEnv");

C:\Users\sadakar\.m2\repository\SADAKAR_POC\SADAKAR_POC\0.0.1-SNAPSHOT>java -DtestEnv=local -jar SADAKAR_POC-0.0.1-SNAPSHOT-jar-with-dependencies.jar

3) How to read the excel test data file from the location where jar is generated ?
Every time when you run scenario(s) or run the jar you CAN NOT edit the excel data file that is bundled inside the jar and it become cumbersome to manually update the excel then bundle it.
This may be tedious job if the test data is huge. To overcome this, it is always a good practice to keep the excel file externally where the jar is going to be generated or where the jar is going be deployed, so I file kept in such location can be accessible with the following snippet in the method.

//This piece of code search for the excel file where the jar is generated or deployed
fileName ="./"+ fileName;
ExcelFile =new FileInputStream(fileName);


Complete picture of these 3 logic(s) are implemented in ExcelUtils.java where the file name is being sent from AddAccount.java with the Sheet name.
To get the Cell data look at readAccountsData method.
ExcelUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.sadakar.excel.utilities;

importjava.io.FileInputStream;
importjava.io.FileNotFoundException;
importjava.io.InputStream;
importorg.apache.poi.ss.usermodel.DataFormatter;
importorg.apache.poi.xssf.usermodel.XSSFCell;
importorg.apache.poi.xssf.usermodel.XSSFSheet;
importorg.apache.poi.xssf.usermodel.XSSFWorkbook;

importcom.sadakar.resource.utilities.Log;

publicclassExcelUtils{

publicstatic XSSFSheet ExcelWSheet;

publicstatic XSSFWorkbook ExcelWBook;

publicstatic XSSFCell Cell;

publicstatic String currentDir = System.getProperty("user.dir");

// public static final String currentDir = System.getProperty("user.dir");

// This method is to set the File path and to open the Excel file, Pass
// Excel Sheet name as Arguments to this method

publicstatic InputStream getResource(String filename){
InputStream inputStream = ExcelUtils.class.getResourceAsStream(filename);
if(null== inputStream){
//fail("Resource not found: `" + filename + "`");
Log.error("Resource not found: `"+ filename +"`");
}
return inputStream;
}

publicstaticvoidsetExcelFile(String fileName, String SheetName)
throws Exception {

InputStream ExcelFile =null;

try{
String testEnv = System.getProperty("testEnv");
if(testEnv !=null&& testEnv.equalsIgnoreCase("local")){

//This piece of code search for the excel file where the jar is generated or deployed
fileName ="./"+ fileName;
ExcelFile =new FileInputStream(fileName);


//This code ships the excel file into the jar
//ExcelFile = getResource("/data/SMAPI_UI_Automation.xlsx");

}else{
fileName ="/data/"+ fileName;
ExcelFile = getResource(fileName);
}

ExcelWBook =new XSSFWorkbook(ExcelFile);
ExcelWSheet = ExcelWBook.getSheet(SheetName);

}catch(FileNotFoundException e){
System.out.println("Excel Reading have problems : "+ e);
Log.error("Excel Reading have problems : "+ e);
}
}

// This method is to read the test data from the Excel cell, in this we are
// passing parameters as Row num and Col num
publicstatic String getCellData(int RowNum,int ColNum)throws Exception {
try{

Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
DataFormatter formatter =new DataFormatter();
String CellData = formatter.formatCellValue(Cell);
return CellData;

}catch(Exception e){
return"";
}
}

}

AddAccount.java 
(This class extends BasePage class that can be removed if you want to use the same code)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.sadakar.cucumber.stepdefinitions;
importorg.openqa.selenium.By;
importorg.openqa.selenium.WebElement;
importcom.sadakar.excel.utilities.ExcelUtils;
importcom.sadakar.resource.utilities.Log;
importcom.sadakar.selenium.common.BasePage;
importcucumber.api.java.en.Then;
importorg.junit.Assert;
importjava.util.concurrent.TimeUnit;

publicclassAddAccountextends BasePage{

ExcelUtils eu =new ExcelUtils();

publicvoidreadAccountsData()throws Exception{

try{
Log.debug("Reading Accounts Excel data file");
ExcelUtils.setExcelFile("Accounts_Test_Data_Automation.xlsx","Accounts");
}
catch(Exception e){
System.out.println("\n Unable to read excel file or Sheet:\n"+e);
Log.error("\n Unable to read excel file or Sheet:\n"+e);
throw e;
}

try{

Log.debug("---------Accounts Test Data------------");
System.out.println("---------Accounts Test Data-------");


Log.debug("AccountID* ="+ExcelUtils.getCellData(1,1));
Log.debug("AccountName* ="+ExcelUtils.getCellData(2,1));

System.out.println(ExcelUtils.getCellData(1,1)+"\n");
System.out.println(ExcelUtils.getCellData(2,1)+"\n");

Log.debug("-----------------------------------------");
System.out.println("---------------------------------");

}catch(Exception e){
Log.error("Unable to display Accounts test data"+e);
System.out.println("Unable to display Accounts test data"+e);
}
}
}


I hope this helps, someone in community.!

Cheers.!

- Sadakar Pochampalli 

Tip : Cucumber options(classpath, tag, glue, pretty and monochrome) for cucumber.api.cli.Main.main method when running the cucumber project from command line

$
0
0
If we wan to run the cucumber project from command line/prompt using executable jar , we should create main method and inside it have to pass string values of cucumber options.

Adding main method for BasePage.java class and appropriate jar assembly plugin in pom.xml with the fully qualified class name say com.sadakar.selenium.common.BasePage
(in which main method is written), generates the MANIFEST.FM file that can be viewed if  extracts the jar

The options for command line differs from what we give in CucumberRunner.java (cucumber runner class with )

These options for command line are presented with -g, -p, -m and etc.
-g for glue code
-p for pretty
-m for monochrome
and to read the .feature files give "classpath:features".


The below piece of code explains how the cucumber options should be passed to main method.
Basepage.java
package com.sadakar.selenium.common;
import org.openqa.selenium.WebDriver;

public class BasePage {

public static WebDriver driver;

public static void main(String args[]) throws Throwable{
try {
cucumber.api.cli.Main.main(
new String[]{
"classpath:features",
"-t","@scenario_AccountPage",
"-g", "com.sadakar.cucumber.stepdefinitions/",
"-g","com.sadakar.cucumber.common",
"-p","pretty",
"-p","json:target/cucumber-reports/Cucumber.json",
"-p", "html:target/cucumber-reports",
"-m"
}
);
}
catch(Exception e) {
System.out.println("Main method exception");
}
}
}

CucumberRunner.java
In standalone cucumber runner class options are represented with tags, glue, plugin and etc.
package com.sadakar.cucumber.runner;

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;


@RunWith(Cucumber.class)
@CucumberOptions
(
features="classpath:features",
tags="@scenario_AddAccountPage",
glue={"com.sadakar.cucumber.stepdefinitions/","com.sadakar.cucumber.common"},
plugin = { "pretty", "json:target/cucumber-reports/Cucumber.json",
"junit:target/cucumber-reports/Cucumber.xml",
"html:target/cucumber-reports"},
monochrome = true
)

public class CucumberRunner {



}


MANIFEST.FM

Manifest-Version: 1.0
Built-By: Sadakar
Class-Path: cucumber-java-1.2.5.jar cucumber-core-1.2.5.jar cucumber-h
 tml-0.2.3.jar cucumber-jvm-deps-1.0.5.jar gherkin-2.12.2.jar cucumber
 -junit-1.2.5.jar junit-4.12.jar hamcrest-core-1.3.jar selenium-java-3
 .141.59.jar selenium-api-3.141.59.jar selenium-chrome-driver-3.141.59
 .jar selenium-edge-driver-3.141.59.jar selenium-firefox-driver-3.141.
 59.jar selenium-ie-driver-3.141.59.jar selenium-opera-driver-3.141.59
 .jar selenium-remote-driver-3.141.59.jar selenium-safari-driver-3.141
 .59.jar selenium-support-3.141.59.jar byte-buddy-1.8.15.jar commons-e
 xec-1.3.jar guava-25.0-jre.jar jsr305-1.3.9.jar checker-compat-qual-2
 .0.0.jar error_prone_annotations-2.1.3.jar j2objc-annotations-1.1.jar
  animal-sniffer-annotations-1.14.jar okhttp-3.11.0.jar okio-1.14.0.ja
 r log4j-1.2.17.jar poi-4.1.0.jar commons-codec-1.12.jar commons-colle
 ctions4-4.3.jar commons-math3-3.6.1.jar poi-ooxml-4.1.0.jar poi-ooxml
 -schemas-4.1.0.jar commons-compress-1.18.jar curvesapi-1.06.jar xmlbe
 ans-3.1.0.jar poi-scratchpad-4.1.0.jar
Created-By: Apache Maven 3.6.3
Build-Jdk: 1.8.0_181
Main-Class: com.inovalon.selenium.common.BasePage


maven-assembly-plugin in pox.xml


<plugin>
<!-- NOTE: We don't need a groupId specification because the group is
org.apache.maven.plugins ...which is assumed by default.
-->
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.sadakar.selenium.common.BasePage</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>


Eclipse command to generate the jar from Maven build: 
clean compile assembly:single install

Hope this helps someone in the community.

Cheers.!
Sadakar Pochampalli 

Tip : Multiple markers at this line - Step definitions detection works only when the project is configured as cucumber project.

$
0
0
This is usually seen in the feature file as a warning message. 

If you install feature file plugin from eclipse market place and if you restart the tool, the existing feature files gets this warning. 

I've observed it in the following eclipse installation: 
Version: 2020-03 (4.15.0)
Build id: 20200313-1211

Right click on the eclipse project -> Configure -->  Convert to Cucumber Project...


References: 
https://stackoverflow.com/questions/58327032/step-definition-detection-only-works-when-project-is-configured-as-cucumber-proj

AutoIT script for windows based chrome authentication in Selenium or Cucumber

$
0
0
Hi,

The following AutoIt script can be used for windows based chrome authentication.

1. Open the website in chrome with windows based pop-up.
2. Open the AutoIT tool and move the "Finder Tool" on to the window.
3. Make a note of "Title" and "Class" of the window.
4. Use the following script with values updated with the "Title" and "Class".
5. Save the file, for example : atuoit_chrome_credentials.au3  (extension should be .au3)
6. Compile the script (right click from the location where the file is saved and compile).
7. Compile generates .exe file , in this case it is : atuoit_chrome_credentials.exe

Call the .exe file before the website get loaded in java file


Runtime.getRuntime().exec("\path to the .exe file\"+autoit_chorme_credentials.exe);


AutoIT code snippet

;RequireAdmin ; unsure if it's needed
;$iSleep = 2000
Opt("WinSearchChildren", 1)
$sUsername="admin"
$sPassword="PaSSWorD2%"
Sleep(1000)
For$i=1To20Step1
Sleep(3000)
$sTitle=WinGetTitle("Sign in")
If$sTitle="sadakar.network.com - Google Chrome"orWinWaitActive("[CLASS:Chrome_WidgetWin_1]") orWinWaitActive("Sign in") Then
Send($sUsername)
Send("{TAB}")
Send($sPassword,1);$SEND_RAW (1)
Send("{TAB}")
Send("{ENTER}")
Exit0
Else
ContinueLoop
EndIf
Next
Exit1


How to find Title and Class from AutoIt tool ? 



Auto reads the credentials while the program runs for chrome based windows authentication pop-up.



- Sadakar Pochampalli

Tip : Code snippet of isSelected() and getAttribute("value") to validate checkbox in a Store page form using java-selenium-cucumber

$
0
0
Hi,

Use case : In a Store page form,
PASS the test : if the store belongs to an internal office
FAIL the test : if the store belongs to external office for sales

NOTE : While creating the Store in the form selected the checkbox so it is an internal store.

label and input type : Is Internal Store ( it is a check box )

@Then("^I verify all the Store details with the values given while creating a new Store$")
publicvoidi_verify_all_the_Store_details_with_the_values_given_while_creating_a_new_Store()throws Throwable {
try{
Log.debug("Comparing Internal Store with the selection while a new Store is created");
Log.debug("Internal Store value while the Store is created is=true");
Log.debug("Get Value of internal Store from UI: "+driver.findElement(By.xpath("//*[@id='isInternalStore']")).getAttribute("value"));

if(
(driver.findElement(By.xpath("//*[@id='isInternalStore']")).isSelected())&&
(driver.findElement(By.xpath("//*[@id='isInternalStore']")).getAttribute("value").toString().equals("true"))
){
Log.debug("Store is equals with the selection while account is created");
}else
{
Assert.fail("else block.......... Store is NOT internal one");
System.out.println("Store is NOT internal one");
}
}catch(Exception e){
Assert.fail("catch block.........Store is NOT internal one"+e);
System.out.println("Store is NOT internal one"+e);
}
}

- Sadakar Pochampalli 

Tip : finding xpath for legend tag using contains

$
0
0

Label content on the web:

xpath: 
//legend[contains(.,'Add Marketing User')]

HTML inspector :


Tip : Run specific cucumber scenario from command line for an executable jar file

Viewing all 261 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>