Planet Jaspersoft

Filter by tags:

August 20, 2020

Hi , 

Bad Design: 
When you call a columnar sub report (i.e., a report split into several columns) in parent report and if applies "Details Overflow" on the sub report element on the parent then the report output loads forever while running on JasperReports server. Eventually this leads to memory leaks and server goes down with 502 Bad Gate Way response. 

Best Practice(s): 
1) In sub report "Page Format" ensure to have "Print Order"="Horizontal". 
      (
         This property also solves another the issue of weird behavior of report output 
         For instance,  
         > Number of output rows for SQL is 21 
        > Sub report is designed to have 12 columns 
        > Sub report height is 106 
        > Parent report height is 400 
        Expected output:
                    When you run the parent report, it has to have 12 columns displayed until the width and 
                   then  remaining columns in the additional space of parent report. 
        Actual output: 
                   Report displays only  6 column output until the width of report, 
                   in the next empty space another 6 columns and so in next empty space.. 
                    This is simply called "vertical order". 
     ).  

2) Ensure that Sub report height = Sum of bands used in sub report. 

3) In the main report, on the sub report element properties always un-check  "Detail Overflow" check box.  

4) Apply "Position Type" ="Float" on the sub reports if there are more than one. 
     This solves overlapping issue. 

Sub Report Design: 

            Tap on to the image for best view in gallery mode 

Parent Report Design: 

    Tap on to the image for best view in gallery mode 


-  Sadakar Pochampalli 






August 20, 2020

Hi, 

Issue :  
The PhantomJS process failed to start.

Observation area : 
While exporting report size of 48 or 50 or more than that to PPT or PDF

 Actual output
Error Message
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRRuntimeException: The PhantomJS process failed to start.

Error Trace
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRRuntimeException: The PhantomJS process failed to start. at com.jaspersoft.jasperreports.fusion.DefaultPptxHandler.exportElement(DefaultPptxHandler.java:31) at net.sf.jasperreports.engine.export.ooxml.JRPptxExporter.exportGenericElement(JRPptxExporter.java:1762) at net.sf.jasperreports.engine.export.ooxml.JRPptxExporter.exportElements(JRPptxExporter.java:578) at net.sf.jasperreports.engine.export.ooxml.JRPptxExporter.exportPage(JRPptxExporter.java:443) at net.sf.jasperreports.engine.export.ooxml.JRPptxExporter.exportReportToStream(JRPptxExporter.java:397) at net.sf.jasperreports.engine.export.ooxml.JRPptxExporter.exportReport(JRPptxExporter.java:264) at com.jaspersoft.jasperserver.war.action.ReportPptxExporter.export(ReportPptxExporter.java:90) at com.jaspersoft.jasperserver.war.action.AbstractReportExporter.exportBuffered(AbstractReportExporter.java:188) at com.jaspersoft.jasperserver.war.action.AbstractReportExporter.export(AbstractReportExporter.java:96) at com.jaspersoft.jasperserver.war.action.ReportExporterAction.export(ReportExporterAction.java:157) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.webflow.action.DispatchMethodInvoker.invoke(DispatchMethodInvoker.java:98) at org.springframework.webflow.action.MultiAction.doExecute(MultiAction.java:123) at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188) at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145) at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51) at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:77) at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188) at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145) at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51) at org.springframework.webflow.engine.ActionList.execute(ActionList.java:155) at org.springframework.webflow.engine.State.enter(State.java:193) at org.springframework.webflow.engine.Transition.execute(Transition.java:227) at org.springframework.webflow.engine.impl.FlowExecutionImpl.execute(FlowExecutionImpl.java:393) at org.springframework.webflow.engine.impl.RequestControlContextImpl.execute(RequestControlContextImpl.java:214) at org.springframework.webflow.engine.TransitionableState.handleEvent(TransitionableState.java:119) at org.springframework.webflow.engine.Flow.handleEvent(Flow.java:555) at org.springframework.webflow.engine.impl.FlowExecutionImpl.handleEvent(FlowExecutionImpl.java:388) at org.springframework.webflow.engine.impl.RequestControlContextImpl.handleEvent(RequestControlContextImpl.java:210) at org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:105) at org.springframework.webflow.engine.State.enter(State.java:194) at org.springframework.webflow.engine.Transition.execute(Transition.java:227) at org.springframework.webflow.engine.impl.FlowExecutionImpl.execute(FlowExecutionImpl.java:393) at org.springframework.webflow.engine.impl.RequestControlContextImpl.execute(RequestControlContextImpl.java:214) at org.springframework.webflow.engine.Flow.handleEvent(Flow.java:560) at org.springframework.webflow.engine.impl.FlowExecutionImpl.handleEvent(FlowExecutionImpl.java:388) at org.springframework.webflow.engine.impl.RequestControlContextImpl.handleEvent(RequestControlContextImpl.java:210) at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:232) at org.springframework.webflow.engine.ViewState.resume(ViewState.java:196) at org.springframework.webflow.engine.Flow.resume(Flow.java:545) at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:261) at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169) at sun.reflect.GeneratedMethodAccessor743.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy140.resumeExecution(Unknown Source) at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183) at org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:933) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:853) at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:827) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.owasp.csrfguard.CsrfGuardFilter.doFilter(CsrfGuardFilter.java:88) at com.jaspersoft.jasperserver.api.security.csrf.JSCsrfGuardFilter.doFilter(JSCsrfGuardFilter.java:69) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.jaspersoft.jasperserver.api.security.csrf.CrossDomainCommunicationFilter.doFilter(CrossDomainCommunicationFilter.java:113) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.jaspersoft.ji.jaxrs.diagnostic.DiagnosticLoggingFilterPRO.doFilter(DiagnosticLoggingFilterPRO.java:41) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at com.jaspersoft.jasperserver.api.security.IPadSupportFilter.doFilter(IPadSupportFilter.java:64) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.war.common.JSSwitchUserProcessingFilter.doFilter(JSSwitchUserProcessingFilter.java:154) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.api.metadata.user.service.impl.MetadataAuthenticationProcessingFilter.doFilter(MetadataAuthenticationProcessingFilter.java:140) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.war.util.RequestParameterAuthenticationFilter.doFilter(RequestParameterAuthenticationFilter.java:96) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.multipleTenancy.MTBasicProcessingFilter.doFilter(MTBasicProcessingFilter.java:192) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.war.UserPreferencesFilter.doFilter(UserPreferencesFilter.java:234) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.ji.license.LicenseCheckFilter.doFilter(LicenseCheckFilter.java:95) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.ji.license.JILicenseFilter.doFilter(JILicenseFilter.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.war.NullFilter.doFilter(NullFilter.java:40) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.war.UserPreferencesFilter.doFilter(UserPreferencesFilter.java:234) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.api.logging.filter.BasicLoggingFilter.doFilter(BasicLoggingFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.api.security.WebAppSecurityFilter.doFilter(WebAppSecurityFilter.java:160) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.war.MultipartRequestWrapperFilter.doFilter(MultipartRequestWrapperFilter.java:92) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.war.NullFilter.doFilter(NullFilter.java:40) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at com.jaspersoft.jasperserver.api.security.encryption.EncryptionFilter.doFilter(EncryptionFilter.java:147) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.jaspersoft.jasperserver.war.util.SessionDecoratorFilter.doFilter(SessionDecoratorFilter.java:60) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.jaspersoft.jasperserver.war.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:64) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.jaspersoft.jasperserver.war.httpheaders.ResourceHTTPHeadersFilter.doFilter(ResourceHTTPHeadersFilter.java:74) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.jaspersoft.jasperserver.war.SessionXssNonceSetterFilter.doFilter(SessionXssNonceSetterFilter.java:64) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.jaspersoft.jasperserver.war.P3PFilter.doFilter(P3PFilter.java:40) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.jaspersoft.jasperserver.war.ProxyUrlFilter.doFilter(ProxyUrlFilter.java:71) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:613) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Caused by: net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRRuntimeException: The PhantomJS process failed to start. at net.sf.jasperreports.phantomjs.ProcessDirector.runRequest(ProcessDirector.java:164) at net.sf.jasperreports.phantomjs.PhantomJS.runRequest(PhantomJS.java:185) at com.jaspersoft.jasperreports.fusion.render.AbstractJRPhantomSvgProducer.getSvg(AbstractJRPhantomSvgProducer.java:83) at com.jaspersoft.jasperreports.fusion.render.FusionSvgImageProducer.createRenderable(FusionSvgImageProducer.java:85) at com.jaspersoft.jasperreports.fusion.render.FusionSvgImageProducer.getImage(FusionSvgImageProducer.java:48) at com.jaspersoft.jasperreports.fusion.DefaultPptxHandler.exportElement(DefaultPptxHandler.java:28) ... 192 more Caused by: net.sf.jasperreports.engine.JRRuntimeException: The PhantomJS process failed to start. at net.sf.jasperreports.phantomjs.PhantomJSProcess.startPhantomJS(PhantomJSProcess.java:125) at net.sf.jasperreports.phantomjs.ProcessFactory.create(ProcessFactory.java:61) at net.sf.jasperreports.phantomjs.ProcessFactory.create(ProcessFactory.java:38) at org.apache.commons.pool2.BasePooledObjectFactory.makeObject(BasePooledObjectFactory.java:60) at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868) at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435) at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363) at net.sf.jasperreports.phantomjs.ProcessDirector.runRequest(ProcessDirector.java:154) ... 197 more

Expected output
Report should be exportable to PPT or PDF

Resolution: 
Increase jasper server memory

August 20, 2020

July 14, 2020

Problem Statement : 
Get part of text "red" in color with "underscore" for text field expression

Solution : 
Use "styled" Markup on text field with expression written with "style" tag. 

Text field expression: 
"Hi, This is regurlar text"+"<style forecolor=\"red\" isUnderline=\"true\">Styled Markup for red color text with underscore in Text Field Expression</style>"+"  This is normal text "+"\n"+"no later than the following date: "+"<style forecolor=\"red\">This text is in red color without underscore</style>"


Sample jrxml design (Tap onto the image for better visibility)

Sample report output(Tap onto the image for better visibility)
JRXML(works from 7.2 studio professional)
<?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="Styled Markup for red color text with underscore in Text Field Expression" pageWidth="620" pageHeight="470" whenNoDataType="AllSectionsNoDetail" columnWidth="620" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="f5ee6cd9-fdbd-4655-a337-ef2568c81a56">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="ireport.jasperserver.url" value="https://dev-lockton-cms.seventablets.com/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.report.resource" value="/organizations/organization_1/Lockton_Reports_1/Test/Styled_Markup_for_red_color_text_with_underscore_in_Text_Field_Expression_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/organizations/organization_1/Lockton_Reports_1/Test/Styled_Markup_for_red_color_text_with_underscore_in_Text_Field_Expression"/>
<property name="com.jaspersoft.studio.report.unit.description" value="001_RP_Stop Loss Marketing Analysis"/>
<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"/>
<queryString language="SQL">
<![CDATA[]]>
</queryString>
<summary>
<band height="460" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<textField>
<reportElement x="50" y="25" width="530" height="40" uuid="c43bf219-e07c-4286-afcd-c8136a487828"/>
<textElement verticalAlignment="Bottom">
<font fontName="Garamond" size="16" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Styled Markup for red color text with underscore in Text Field Expression"]]></textFieldExpression>
</textField>
<textField>
<reportElement mode="Opaque" x="30" y="100" width="35" height="35" forecolor="#FFFFFF" backcolor="#000000" uuid="3edcc7ee-d3fa-4bc7-a02e-d7744e776592">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Garamond" size="16" isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA["1"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="65" y="100" width="485" height="35" uuid="3261f9a0-a9c6-460e-9943-87c9c3cd2dad">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="10"/>
<textElement textAlignment="Left" verticalAlignment="Middle" markup="styled"/>
<textFieldExpression><![CDATA["Hi, This is regurlar text"+"<style forecolor=\"red\" isUnderline=\"true\">Styled Markup for red color text with underscore in Text Field Expression</style>"+" This is normal text "+"\n"+"no later than the following date: "+"<style forecolor=\"red\">This text is in red color without underscore</style>"]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>

July 14, 2020

July 10, 2020

Problem statement : 
1) Take summary band to keep table component i.e., disable all of the remaining bands
2) Feed table component with SQL of only few rows output say 8 rows
Save the report, ideally the report should get within  a single page where my target exporter is PPT and  as the number of rows shall fit within page/slide and the size of text fields are small(in total column header=20, detail cell =15 i.e., total of 35 px ) BUT an extra blank page is displaying in addition of actual output. 

It's relatively very simple but experimenting with properties always consumes a lot of resource time. After trying with Stretch, PositionType and other deprecated properties, just recollected how excel output can be displayed in single sheet. Just mimicked the property for my requirement to get it as single PPT slide. 

  

Solution:
It's "Ignore Pagination" property at report level. i.e., select the report name from "Outline" then in the properties select "Ignore Pagination" property. That's it. 



 

July 10, 2020

July 6, 2020

Visualization :  Column / Vertical bar chart
Problem statement : How to write highcharts function in Jasperreport expression ?
                                  Add a $ sign to Y axis labels 
Navigation : YAxis > labels > formatter > Select for expression 

NOTE : Ensure to add the below property in jasperreports.properties file
com.jaspersoft.jasperreports.highcharts.function.properties.allowed=true

Path : C:\Jaspersoft\jasperreports-server-7.5.0\apache-tomcat\webapps\jasperserver-pro\WEB-INF\classes


Sample screenshot: 


Sample output: 


References: 
JRXML (works on 7.2 studio professional)
<?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="Stop Loss Plan Performance" pageWidth="620" pageHeight="470" whenNoDataType="AllSectionsNoDetail" columnWidth="620" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="f5ee6cd9-fdbd-4655-a337-ef2568c81a56">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<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="/LOCKTON_2020_21/S8_Stop_Loss_Plan_Performance_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/LOCKTON_2020_21/S8_Stop_Loss_Plan_Performance"/>
<property name="com.jaspersoft.studio.report.unit.description" value="001_RP_Stop Loss Marketing Analysis"/>
<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="com.jaspersoft.jasperreports.highcharts.interactive" value="false"/>
<subDataset name="Dataset1-Claims Vs Premium" uuid="ba6bd55c-4dcd-431c-aa4b-587d99dd0b60">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<queryString language="SQL">
<![CDATA[SELECT '2018' AS year, 400000 AS value, 'Premium' AS PremiumClaim
UNION ALL
SELECT '2018' AS year, 850000 AS value, 'Claim' AS PremiumClaim
UNION ALL
SELECT '2019' AS year, 450000 AS value, 'Premium' AS PremiumClaim
UNION ALL
SELECT '2019' AS year, 60000 AS value, 'Claim' AS PremiumClaim
UNION ALL
SELECT '2020' AS year, 210000 AS value, 'Premium' AS PremiumClaim
UNION ALL
SELECT '2020' AS year, 5000 AS value, 'Claim' AS PremiumClaim]]>
</queryString>
<field name="year" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="year"/>
</field>
<field name="value" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="value"/>
</field>
<field name="premiumclaim" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="premiumclaim"/>
</field>
</subDataset>
<queryString language="SQL">
<![CDATA[]]>
</queryString>
<summary>
<band height="460" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<image>
<reportElement x="0" y="70" width="330" height="4" uuid="6c9ee3ac-3d60-4c0e-a2d3-8d09a4777b01">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<printWhenExpression><![CDATA[1==0]]></printWhenExpression>
</reportElement>
<imageExpression><![CDATA["repo:/Test/Images/test/horizontal_heading_bar.png"]]></imageExpression>
</image>
<textField>
<reportElement x="50" y="25" width="530" height="40" uuid="c43bf219-e07c-4286-afcd-c8136a487828"/>
<textElement verticalAlignment="Bottom">
<font fontName="Garamond" size="30"/>
</textElement>
<textFieldExpression><![CDATA["Test"]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="70" y="120" width="550" height="280" uuid="fc2b6ea6-7033-4af9-aa74-9efda7096ec8"/>
<hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="Column">
<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="legend.itemStyle.fontSize" value="8px"/>
<hc:chartProperty name="yAxis.labels.formatter">
<hc:propertyExpression><![CDATA["function() {return '$' + this.axis.defaultLabelFormatter.call(this);}"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="yAxis.tickInterval_customSimpleMode" value="true"/>
<hc:chartProperty name="yAxis.tickInterval">
<hc:propertyExpression><![CDATA[200000]]></hc:propertyExpression>
</hc:chartProperty>
</hc:chartSetting>
<multiAxisData>
<multiAxisDataset>
<dataset>
<datasetRun subDataset="Dataset1-Claims Vs Premium" uuid="e9b1c867-29a5-4cd7-abd7-76b0d846367f"/>
</dataset>
</multiAxisDataset>
<dataAxis axis="Rows">
<axisLevel name="Level1">
<labelExpression><![CDATA["Level Label expression"]]></labelExpression>
<axisLevelBucket order="None" class="java.lang.Comparable">
<bucketExpression><![CDATA[$F{year}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<dataAxis axis="Columns">
<axisLevel name="Series1">
<labelExpression><![CDATA[]]></labelExpression>
<axisLevelBucket order="None" class="java.lang.Comparable">
<bucketExpression><![CDATA[$F{premiumclaim}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<multiAxisMeasure name="Measure1" class="java.lang.Number" calculation="Nothing">
<labelExpression><![CDATA["Value:"]]></labelExpression>
<valueExpression><![CDATA[$F{value}]]></valueExpression>
</multiAxisMeasure>
</multiAxisData>
<hc:series name="Measure1"/>
</hc:chart>
</componentElement>
</band>
</summary>
</jasperReport>

July 6, 2020

July 1, 2020

Sample Design


Sample Output
Text field expression
"\u25AA\u0020This is small square bullet\n\n\u25fc\u0020This is medium square bullet\n\n\u25fe\u0020This is square bullet\n\n\u25a1\u0020This is square bullet\n\n\u25fd\u0020This is square bullet"

References:

JRXML: (Version 7.2 pro)

<?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="Renewal Packet Outline" pageWidth="620" pageHeight="470" whenNoDataType="AllSectionsNoDetail" columnWidth="620" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="f5ee6cd9-fdbd-4655-a337-ef2568c81a56">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="ireport.jasperserver.url" value="https://dev-lockton-cms.seventablets.com/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.report.resource" value="/organizations/organization_1/Lockton_Reports_1/Sub_Reports/Stoploss_Renewal_Packet_Sub_Reports/Renewal_Packet_Outline_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/organizations/organization_1/Lockton_Reports_1/Sub_Reports/Stoploss_Renewal_Packet_Sub_Reports/Renewal_Packet_Outline"/>
<property name="com.jaspersoft.studio.report.unit.description" value="001_RP_Stop Loss Marketing Analysis"/>
<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"/>
<queryString language="SQL">
<![CDATA[]]>
</queryString>
<summary>
<band height="460" splitType="Stretch">
<image>
<reportElement x="0" y="70" width="330" height="4" uuid="6c9ee3ac-3d60-4c0e-a2d3-8d09a4777b01">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<imageExpression><![CDATA["repo:/Lockton_Reports_1/Images/Renewal_Packet_Images/horizontal_heading_bar.png"]]></imageExpression>
</image>
<textField>
<reportElement x="50" y="26" width="350" height="44" uuid="c43bf219-e07c-4286-afcd-c8136a487828"/>
<textElement verticalAlignment="Bottom">
<font fontName="Garamond" size="30"/>
</textElement>
<textFieldExpression><![CDATA["Unicode Square Bullets Demo"]]></textFieldExpression>
</textField>
<textField>
<reportElement mode="Opaque" x="121" y="150" width="419" height="100" forecolor="#FFFFFF" backcolor="#3C6280" uuid="68d10f97-69cf-4fae-85b0-f2b5fdb33e73"/>
<box leftPadding="5"/>
<textElement markup="none">
<font fontName="Segoe UI" size="12"/>
</textElement>
<textFieldExpression><![CDATA["\u25AA\u0020This is small square bullet\n\n\u25fc\u0020This is medium square bullet\n\n\u25fe\u0020This is square bullet\n\n\u25a1\u0020This is square bullet\n\n\u25fd\u0020This is square bullet"]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>



July 1, 2020

June 5, 2020

Hi,


In this blog, we'll discuss below real time use cases of data tables automation in selenium.

1) How to navigate through a data table buttons till the last page ?
2) How to calculate the actual row count of data table ?
3) Compare the actual row count to the displayed row count.


Below is the flow..
1)  Declare and initiate the web driver.
2)  Navigate to the data table on web page.
3)  Create a list and store the "names" column data values for the first page (i.e., for first 10 values)
4)  Logic : Traverse through the table until Next button get disabled (use while loop).
5)  Logic : add the elements during the looping to the list (use for loop to add the list created in #3)
6) Calculate the size of the list i.e., actual count of data table.
7) Extract the displayed count i..e, displayed count of data table on web page.
8) Compare the actual count with displayed count.

Take a look at the lines highlighted in light green color in the following code that has the above flow.

Please watch this space for video tutorial to walk through the code



DataTableButtonsNavigationActualVsDisplayedRowCount.java
package selenium.datatables;

import java.util.ArrayList;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

@SuppressWarnings("unused")
public class DataTableButtonsNavigationActualVsDisplayedRowCount {

public static WebDriver driver;

public static void main(String[] args) throws Exception {

System.setProperty("webdriver.chrome.driver", "D:\\006_trainings\\chromedriver_83.exe");
System
.setProperty("webdriver.chrome.silentOutput", "true");

driver
= new ChromeDriver();
driver.get("https://datatables.net/examples/basic_init/zero_configuration.html");
driver
.manage().window().maximize();
compareDispalyedRowCountToActualRowCount
();
}

public static void compareDispalyedRowCountToActualRowCount() throws Exception {

try {
Thread
.sleep(5000);
List<WebElement> namesElements = driver.findElements(By.cssSelector("#example>tbody>tr>td:nth-child(1)"));
System
.out.println("size of names elements : " + namesElements.size());

List<String> names = new ArrayList<String>();
//Adding column1 elements to the list
for (WebElement nameEle : namesElements) {
names.add(nameEle.getText());
}
//Displaying the list elements on console
for (WebElement s : namesElements) {
System
.out.println(s.getText());
}

//locating next button
String nextButtonClass = driver.findElement(By.id("example_next")).getAttribute("class");

//traversing through the table until the last button and adding names to the list defined about
while (!nextButtonClass.contains("disabled")) {
driver.findElement(By.id("example_next")).click();
Thread.sleep(1000);
namesElements = driver.findElements(By.cssSelector("#example>tbody>tr>td:nth-child(1)"));
for (WebElement nameEle : namesElements) {
names.add(nameEle.getText());
}
nextButtonClass = driver.findElement(By.id("example_next")).getAttribute("class");
}
//printing the whole list elements
for (String name : names) {
System
.out.println(name);
}
//counting the size of the list
int actualCount = names.size();
System
.out.println("Total number of names :" + actualCount);

//locating displayed count
String displayedCountString = driver.findElement(By.id("example_info")).getText().split(" ")[5];
int displayedCount = Integer.parseInt(displayedCountString);

System
.out.println("Total Number of Displayed Names count:" + displayedCount);

Thread
.sleep(1000);

// Actual count calculated Vs Dispalyed Count
if (actualCount == displayedCount) {
System
.out.println("Actual row count = Displayed row Count");
} else {
System
.out.println("Actual row count != Displayed row Count");
throw new Exception("Actual row count != Displayed row Count");
}
} catch (Exception e) {
e
.printStackTrace();
}
}
}

References: 
1) https://www.youtube.com/watch?v=jD5eWhNsaRk

Hope you find this is useful, stay tuned for more automation.!

June 5, 2020

June 4, 2020

Hi,

When you receive the following DEBUG for Maven based cucumber java selenium project that is configured with extent reports, it can be fixed in log4j.properties by adding the following property.

Fix : in log4j.properties
log4j.logger.freemarker.cache = INFO, CONSOLE

Issue:
2020-06-05 09:13:30 DEBUG cache:45 - Couldn't find template in cache for "index.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:30 DEBUG cache:45 - TemplateLoader.findTemplateSource("index_en.ftl"): Not found
2020-06-05 09:13:30 DEBUG cache:45 - TemplateLoader.findTemplateSource("index.ftl"): Found
2020-06-05 09:13:30 DEBUG cache:45 - Loading template for "index.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/index.ftl"
2020-06-05 09:13:31 DEBUG cache:45 - Couldn't find template in cache for "head.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("head_en.ftl"): Not found
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("head.ftl"): Found
2020-06-05 09:13:31 DEBUG cache:45 - Loading template for "head.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/head.ftl"
2020-06-05 09:13:31 DEBUG cache:45 - Couldn't find template in cache for "nav.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("nav_en.ftl"): Not found
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("nav.ftl"): Found
2020-06-05 09:13:31 DEBUG cache:45 - Loading template for "nav.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/nav.ftl"
2020-06-05 09:13:31 DEBUG cache:45 - Couldn't find template in cache for "test-view/test-view.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("test-view/test-view_en.ftl"): Not found
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("test-view/test-view.ftl"): Found
2020-06-05 09:13:31 DEBUG cache:45 - Loading template for "test-view/test-view.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/test-view/test-view.ftl"
2020-06-05 09:13:31 DEBUG cache:45 - Couldn't find template in cache for "test-view/test-view-charts.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("test-view/test-view-charts_en.ftl"): Not found
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("test-view/test-view-charts.ftl"): Found
2020-06-05 09:13:31 DEBUG cache:45 - Loading template for "test-view/test-view-charts.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/test-view/test-view-charts.ftl"
2020-06-05 09:13:31 DEBUG cache:45 - Couldn't find template in cache for "test-view/bdd.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("test-view/bdd_en.ftl"): Not found
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("test-view/bdd.ftl"): Found
2020-06-05 09:13:31 DEBUG cache:45 - Loading template for "test-view/bdd.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/test-view/bdd.ftl"
2020-06-05 09:13:31 DEBUG cache:45 - "test-view/bdd.ftl"("en", UTF-8, parsed) cached copy not yet stale; using cached.
2020-06-05 09:13:31 DEBUG cache:45 - "test-view/bdd.ftl"("en", UTF-8, parsed) cached copy not yet stale; using cached.
2020-06-05 09:13:31 DEBUG cache:45 - Couldn't find template in cache for "category-view/category-view.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("category-view/category-view_en.ftl"): Not found
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("category-view/category-view.ftl"): Found
2020-06-05 09:13:31 DEBUG cache:45 - Loading template for "category-view/category-view.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/category-view/category-view.ftl"
2020-06-05 09:13:31 DEBUG cache:45 - Couldn't find template in cache for "author-view/author-view.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("author-view/author-view_en.ftl"): Not found
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("author-view/author-view.ftl"): Found
2020-06-05 09:13:31 DEBUG cache:45 - Loading template for "author-view/author-view.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/author-view/author-view.ftl"
2020-06-05 09:13:31 DEBUG cache:45 - Couldn't find template in cache for "exception-view/exception-view.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("exception-view/exception-view_en.ftl"): Not found
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("exception-view/exception-view.ftl"): Found
2020-06-05 09:13:31 DEBUG cache:45 - Loading template for "exception-view/exception-view.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/exception-view/exception-view.ftl"
2020-06-05 09:13:31 DEBUG cache:45 - Couldn't find template in cache for "dashboard-view/dashboard-view.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("dashboard-view/dashboard-view_en.ftl"): Not found
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("dashboard-view/dashboard-view.ftl"): Found
2020-06-05 09:13:31 DEBUG cache:45 - Loading template for "dashboard-view/dashboard-view.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/dashboard-view/dashboard-view.ftl"
2020-06-05 09:13:31 DEBUG cache:45 - Couldn't find template in cache for "logs-view/testrunner-logs-view.ftl"("en", UTF-8, parsed); will try to load it.
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("logs-view/testrunner-logs-view_en.ftl"): Not found
2020-06-05 09:13:31 DEBUG cache:45 - TemplateLoader.findTemplateSource("logs-view/testrunner-logs-view.ftl"): Found
2020-06-05 09:13:31 DEBUG cache:45 - Loading template for "logs-view/testrunner-logs-view.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/sadakarp/.m2/repository/E1SmapiUiAutomation/E1SmapiUiAutomation/0.0.1-SNAPSHOT/E1SmapiUiAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/com/aventstack/extentreports/view/html-report/logs-view/testrunner-logs-view.ftl"

June 4, 2020

May 28, 2020

Hi, in this post, we will learn about how to auto compare the displayed drop down select values to the user expected drop down values.

i.e , compare "actual values displayed" to the "user expected values"  for the drop down select for a web data table.

Zoom-In by tapping the image:

The approach is as follows: 
1) Declare a list for user expected values of an integer(later in the code convert to sting)
     or String type.
2) Locate the drop down select element on the web using xpath locator technique.
3) Create an object of "Select" class with the argument of  drop down select element. (from #2)
4) Store the values of actual values displayed in another list of type WebElement
5) Compare the two lists  and confirm the equality.

user expected values
List<Integer> expectedDropDownValues = new ArrayList<Integer>()
{
{
add
(10);
add
(25);
add
(50);
add
(100);
}
};

actual values displayed
WebElement entriesDropDownLocator = driver.findElement(By.xpath("//select[@name='example_length']"));

Select entriesDropDown = new Select(entriesDropDownLocator);

List
<WebElement> actualDropDownValues = entriesDropDown.getOptions();

Compare the two lists
for(int i=0;i<actualDropDownValues.size();i++) {

if(actualDropDownValues.get(i).getText().equals(expectedDropDownValues.get(i).toString())) {

System
.out.println("Value Matching :"+"Actual List Value="+actualDropDownValues.get(i).getText()+" And Expected Value="+expectedDropDownValues.get(i));
}else {
System
.out.println("Value Not Matching :"+"Actual List Value="+actualDropDownValues.get(i).getText()+" And Expected Value="+expectedDropDownValues.get(i));
}
}

CompareDisplayedDropdownSelectValuesWithActualValues.java
package selenium.datatables;

import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;


public class CompareDisplayedDropdownSelectValuesWithActualValues {

public static WebDriver driver;

public void compareDispalyedRowCountToActualRowCount() throws Exception {

@SuppressWarnings("serial")
List<Integer> expectedDropDownValues = new ArrayList<Integer>()
{
{
add(10);
add(25);
add(50);
add(100);
}
         };

System.out.println("Expected dropdown values for accounts table");

for (Integer expectedOptions : expectedDropDownValues) {
System.out.println(expectedOptions.toString());
}

WebElement entriesDropDownLocator = driver.findElement(By.xpath("//select[@name='example_length']"));

Select entriesDropDown = new Select(entriesDropDownLocator);
List<WebElement> actualDropDownValues = entriesDropDown.getOptions();

System.out.println("Actual dropdown values from accounts table");
for (WebElement actualValues : actualDropDownValues) {
System.out.println(actualValues.getText());
}
System.out.println("Compare the actual values with the expected values for dropdown");

for(int i=0;i<actualDropDownValues.size();i++) {

if(actualDropDownValues.get(i).getText().equals(expectedDropDownValues.get(i).toString())) {

System.out.println("Value Matching :"+"Actual List Value="+actualDropDownValues.get(i).getText()+" And Expected Value="+expectedDropDownValues.get(i));
}else {
System.out.println("Value Not Matching :"+"Actual List Value="+actualDropDownValues.get(i).getText()+" And Expected Value="+expectedDropDownValues.get(i));
}
}
}

public void closeDriver() {
driver.close();
}
public void quitDriver() {
driver.quit();
}

public static void main(String[] args) throws Exception {

CompareDisplayedDropdownSelectValuesWithActualValues c = new CompareDisplayedDropdownSelectValuesWithActualValues();

System.setProperty("webdriver.chrome.driver", "D:\\006_trainings\\chromedriver.exe");
System.setProperty("webdriver.chrome.silentOutput","true" );

driver = new ChromeDriver();
driver.get("https://datatables.net/examples/basic_init/zero_configuration.html");
driver.manage().window().maximize();
c.compareDispalyedRowCountToActualRowCount();

c.closeDriver();
c.quitDriver();
}
}

Console Log:
Expected dropdown values for accounts table
10
25
50
100
Actual dropdown values from accounts table
10
25
50
100
Compare the actual values with the expected values for dropdown
Value Matching :Actual List Value=10 And Expected Value=10
Value Matching :Actual List Value=25 And Expected Value=25
Value Matching :Actual List Value=50 And Expected Value=50
Value Matching :Actual List Value=100 And Expected Value=100

I hope you find this post is useful, stay tuned for more automation.!

May 28, 2020

Hi , In this tutorial, we'll learn about how to compare displayed row count on page is equals to data table row count in java selenium.

There are several ways to accomplish this, by the time I write this article, I've come across two ways.
They are
1) Calculate the no. of rows in data table by navigating through the pagination buttons.
2) Calculate the no. of rows in data table by using jQuery "length" function.

We will see the latter implementation in this post.

Tap on to the image to get better visibility of content : 

The approach is as follows.
1. Wait for sometime to load the page for which data table is present.
2. Take an integer variable say "dataTableActualRowCount" with 0 as the default value.
3. Create  JavascriptExecutor object for the driver.
4. Use jQuery "length" function technique within java-selenium code.
5. jQuery stores the value in Object so convert it into integer and store the jquery returned length in
     dataTableActualRowCount
6. Find the displayed count from bottom of the page using WebElement finder technique and store it
    in another integer variable say "displayedCountOfRowsOnPage".
7. Now, Compare the values of "dataTableActualRowCount" and
      "displayedCountOfRowsOnPage".
8. If dataTableActualRowCount == displayedCountOfRowsOnPage then "displayed row count
   on page is equals to data table row count " else "displayed row count on page is NOT equals
   to data  table row count".

dataTableActualRowCount - calculating using jQuery "length" function
int dataTableActualRowCount=0;

JavascriptExecutor js
=(JavascriptExecutor)driver;

dataTableActualRowCount
= ((Number)js.executeScript("return $('#example').DataTable().rows().data().toArray().length;")).intValue();

System
.out.println("Data table row count="+dataTableActualRowCount);

displayedCountOfRowsOnPage - finding through WebElement
String displayedCount = driver.findElement(By.id("example_info")).getText().split(" ")[5];

int displayedCountOfRowsOnPage = Integer.parseInt(displayedCount);

System
.out.println("Data table display count on page ="+displayedCountOfRowsOnPage);

CompareDisplayedRowCountToDataTableRowCount.java
package selenium.datatables;


import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class CompareDisplayedRowCountToDataTableRowCount {

public static WebDriver driver;
public static void main(String[] args) throws Exception {

System.setProperty("webdriver.chrome.driver", "D:\\006_trainings\\chromedriver.exe");
System.setProperty("webdriver.chrome.silentOutput","true" );

driver = new ChromeDriver();
driver.get("https://datatables.net/examples/basic_init/zero_configuration.html");
driver.manage().window().maximize();
compareDispalyedRowCountToActualRowCount();
}


public static void compareDispalyedRowCountToActualRowCount() throws Exception {
Thread.sleep(10000);

int dataTableActualRowCount=0;

JavascriptExecutor js=(JavascriptExecutor)driver;

dataTableActualRowCount = ((Number)js.executeScript("return $('#example').DataTable().rows().data().toArray().length;")).intValue();
System.out.println("Data table row count="+dataTableActualRowCount);

String displayedCount = driver.findElement(By.id("example_info")).getText().split(" ")[5];

int displayedCountOfRowsOnPage = Integer.parseInt(displayedCount);
System.out.println("Data table display count on page ="+displayedCountOfRowsOnPage);

if(Integer.compare(dataTableActualRowCount, displayedCountOfRowsOnPage)==0) {
System.out.println("Displayed count on page is equals to the data table row count ");
}else {
System.out.println("Displayed count on page is NOT equals to the data table row count");
throw new Exception("Displayed count on page is NOT equals to the data table row count");
}
}
}


I hope you find this tutorial is useful, stay tuned for more automation.!

- Sadakar Pochampalli

May 28, 2020

Pages

Feedback
randomness