tag:blogger.com,1999:blog-84840563380957544802024-03-10T14:40:27.737+05:30Pochampalli IT Labs<b>
QA Automation/Manual: API and Web/UI : Java, Cucumber, Selenium, Junit, TestNG, Java Script, Postman/Newman, Maven, TestLink, Azure Test Plans, Jira, AutoIT<br>
CI/CD: Azure DevOps, Team City, Batch Scripting, Perl Scripting, Chef <br>
Business Intelligence : Jaspersoft, Pentaho, Tableau, Power BI | Reports, Dashboards, Analysis, Data Integration, ETL <br>
Cloud Computing & OS : AWS, Cent OS
</b>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.comBlogger342125tag:blogger.com,1999:blog-8484056338095754480.post-8240003400710004692024-02-09T23:04:00.004+05:302024-02-09T23:04:40.636+05:30Tip: Connection Expression for Sub report for XmlDataSource in jasper reports<p> In an XML data adapter report, when you call a sub report of same data adapter in master report, one can use below expression to establish connection. </p><p><b><span style="color: #073763;">((net.sf.jasperreports.engine.data.JRXmlDataSource)</span></b></p><p><span style="background-color: #cccccc; white-space: normal;"><b><span style="color: #073763;"><span style="white-space: pre;"> </span>$P{REPORT_DATA_SOURCE}).subDataSource("/tags/employee")</span></b></span></p><p><span style="white-space: normal;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEj7I4mzY_iRh6e_gVtLL3s1IG2Rh6Rt0MEhYo0WhqDyDX0yx1H_LSB9je0U2OwXZu0q3U1tMSfp-DOMRthg_TbaDBijTYb1U4kZyS1KVRnRhpJCEVK_uN6wpdih2mKzi-o-JyouQJGuGIQwlQsl-W8ARg8DtksjwnlsqDfoKjqVwgFRaLTgd2fEG_X2bk0i" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="534" data-original-width="887" src="https://blogger.googleusercontent.com/img/a/AVvXsEj7I4mzY_iRh6e_gVtLL3s1IG2Rh6Rt0MEhYo0WhqDyDX0yx1H_LSB9je0U2OwXZu0q3U1tMSfp-DOMRthg_TbaDBijTYb1U4kZyS1KVRnRhpJCEVK_uN6wpdih2mKzi-o-JyouQJGuGIQwlQsl-W8ARg8DtksjwnlsqDfoKjqVwgFRaLTgd2fEG_X2bk0i=s16000" /></a></div><br /><br /><p></p>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-31737331046375407652023-12-22T12:03:00.006+05:302023-12-22T12:06:30.842+05:30How to stop auto downloading of log4j-1.2.12 in selenium , testng, maven project ?<p>When you create a new maven project in eclipse and try to update it, you would likely to an auto download of 1.2.12 log4j jar that is variable. <br />One possible reason I came across on this is due to 1.5 java version dependencies added while creating a new maven project and if you update or wait for the pom to download all the dependencies the project auto downloads this and it may lead to security concerns. </p><p>The solution that worked for me was to update the execution environment in maven project i.e., to Java 11. </p><p></p><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Having 1.x version of log4j is a serious security concern in modern cloud or on premise based solutions. </div></div><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ4rdotjl42blmuHbS2AluXprY2ImcPluQStflcJsbJmgffLYA6wc2zaaz0ztqH3KJJXIMj5KjxRg6Heo8w6joT9yw9xqs1hkBt5xtPhR_z0aiV80-V_uHoE9RbnUz_vr7Gmzd0jtOeI7XDXzzh6JMWsCIMYxKyXHpSk_wCEapkItNLSoQrvvSHMekmcJs/s707/log4j.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="220" data-original-width="707" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ4rdotjl42blmuHbS2AluXprY2ImcPluQStflcJsbJmgffLYA6wc2zaaz0ztqH3KJJXIMj5KjxRg6Heo8w6joT9yw9xqs1hkBt5xtPhR_z0aiV80-V_uHoE9RbnUz_vr7Gmzd0jtOeI7XDXzzh6JMWsCIMYxKyXHpSk_wCEapkItNLSoQrvvSHMekmcJs/s16000/log4j.PNG" /></a></div><br /><div class="separator" style="clear: both; text-align: left;">Update the Execution environment from 1.5 to 1.8 or 9, 10 or 11 or to higher version</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpRD7nriMw8uuGEEJdTtupjEh8MFfyd98XI1W2Ha-LT1xGJugHZFFDIOgQBm8YqEEx8HkzYNRnGtpMJfHlOaFfG3AGzliuYqgcah0mAVZcC6n5GLh9ZVORcq4Dw3ux3LDgwulaiBpGraSBr0jaB4gvTTGZuJGyo8x1f-JgftHSTJ_XcM4ykEo4fTG0eFGT/s927/execution.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="647" data-original-width="927" height="447" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpRD7nriMw8uuGEEJdTtupjEh8MFfyd98XI1W2Ha-LT1xGJugHZFFDIOgQBm8YqEEx8HkzYNRnGtpMJfHlOaFfG3AGzliuYqgcah0mAVZcC6n5GLh9ZVORcq4Dw3ux3LDgwulaiBpGraSBr0jaB4gvTTGZuJGyo8x1f-JgftHSTJ_XcM4ykEo4fTG0eFGT/w640-h447/execution.PNG" width="640" /></a></div><br /><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUakEzl1CzBWYGINNBJWi6Q_hGf-Y_AtzGCkmik6f_x_1ovXRMMCi_WF35lug2X8AcKoM8YBu-RAchgkNQwqnbyRXVjeYWeCf-DKYqM4qZLO1ghviGU0O_z_Gbk58mWq7JmGa7JimQO9zM-efVkfmR2qIMFJhoxdE8bWufDYT2mauwjlvfIgxI4slzENBg/s281/mavenproject.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="194" data-original-width="281" height="194" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUakEzl1CzBWYGINNBJWi6Q_hGf-Y_AtzGCkmik6f_x_1ovXRMMCi_WF35lug2X8AcKoM8YBu-RAchgkNQwqnbyRXVjeYWeCf-DKYqM4qZLO1ghviGU0O_z_Gbk58mWq7JmGa7JimQO9zM-efVkfmR2qIMFJhoxdE8bWufDYT2mauwjlvfIgxI4slzENBg/s1600/mavenproject.PNG" width="281" /></a></div><br /><div><br /></div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-4090268029939451502023-11-04T12:34:00.005+05:302023-11-04T12:34:49.711+05:30java.lang.NoSuchMethodError: 'void org.testng.TestRunner.(org.testng.internal.IConfiguration, org.testng.ISuite, org.testng.xml.XmlTest, boolean, java.util.Collection, java.util.List)'<p>When you see below error add : TestNG to the build path</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhxsgF1jSDcqdUk1rXA2q_Q-XCWHcDrFo-i5TW6etb0lDb53oLi-t21sr_TOyzAw-qO5JPo6sEBvEvEqtvTDfrt2DoE6lHwO4SIFL0zZmvWs3Y6eKNcLetsfplQHUaWRuV4gxpCjO41kZhF_CoSHWhTVcXaozVe8gA_0QNBcS9SxHK1WI7FeVw6pdOVe-2B" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="241" data-original-width="238" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEhxsgF1jSDcqdUk1rXA2q_Q-XCWHcDrFo-i5TW6etb0lDb53oLi-t21sr_TOyzAw-qO5JPo6sEBvEvEqtvTDfrt2DoE6lHwO4SIFL0zZmvWs3Y6eKNcLetsfplQHUaWRuV4gxpCjO41kZhF_CoSHWhTVcXaozVe8gA_0QNBcS9SxHK1WI7FeVw6pdOVe-2B" width="237" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiir8-fUnbhNeMox5oljaskrHcM-Qc6dJobZAZWEcB7cJZdGgWMGD6aq1Nn1yYRwTZ0Oxx2BuRTL-kWl20z1lrpq0zsIibh8KzacD960GSY576FqMNjlXSjBZ5OLZWTyuJfL6ZN6TkOKaxQtLZ79Y3I5Y19IDzb6TEeWkBFU7Y27mQf3VM3X_iDcLzEOcjg" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="546" data-original-width="925" src="https://blogger.googleusercontent.com/img/a/AVvXsEiir8-fUnbhNeMox5oljaskrHcM-Qc6dJobZAZWEcB7cJZdGgWMGD6aq1Nn1yYRwTZ0Oxx2BuRTL-kWl20z1lrpq0zsIibh8KzacD960GSY576FqMNjlXSjBZ5OLZWTyuJfL6ZN6TkOKaxQtLZ79Y3I5Y19IDzb6TEeWkBFU7Y27mQf3VM3X_iDcLzEOcjg=s16000" /></a></div><br /> <div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #333333;">[</span>RemoteTestNG<span style="color: #333333;">]</span> detected TestNG version <span style="color: #6600ee; font-weight: bold;">7.8</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Failed to load <span style="color: #008800; font-weight: bold;">class</span> <span style="background-color: #ffaaaa; color: red;">"</span><span style="color: #bb0066; font-weight: bold;">org</span><span style="color: #333333;">.</span><span style="color: #0000cc;">slf4j</span><span style="color: #333333;">.</span><span style="color: #0000cc;">impl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">StaticLoggerBinder</span><span style="background-color: #ffaaaa; color: red;">"</span><span style="color: #333333;">.</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Defaulting to no<span style="color: #333333;">-</span>operation <span style="color: #333333;">(</span>NOP<span style="color: #333333;">)</span> logger implementation
<span style="color: #997700; font-weight: bold;">SLF4J:</span> See <span style="color: #997700; font-weight: bold;">http:</span><span style="color: #888888;">//www.slf4j.org/codes.html#StaticLoggerBinder for further details.</span>
java<span style="color: #333333;">.</span><span style="color: #0000cc;">lang</span><span style="color: #333333;">.</span><span style="color: #0000cc;">NoSuchMethodError</span><span style="color: #333333;">:</span> <span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333399; font-weight: bold;">void</span> org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestRunner</span><span style="color: #333333;">.<</span>init<span style="color: #333333;">>(</span>org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">IConfiguration</span><span style="color: #333333;">,</span> org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ISuite</span><span style="color: #333333;">,</span> org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">xml</span><span style="color: #333333;">.</span><span style="color: #0000cc;">XmlTest</span><span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">boolean</span><span style="color: #333333;">,</span> java<span style="color: #333333;">.</span><span style="color: #0000cc;">util</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Collection</span><span style="color: #333333;">,</span> java<span style="color: #333333;">.</span><span style="color: #0000cc;">util</span><span style="color: #333333;">.</span><span style="color: #0000cc;">List</span><span style="color: #333333;">)</span><span style="background-color: #ffaaaa; color: red;">'</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">support</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteTestNG6_12</span>$1<span style="color: #333333;">.</span><span style="color: #0000cc;">newTestRunner</span><span style="color: #333333;">(</span>RemoteTestNG6_12<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">33</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">support</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteTestNG6_12</span>$DelegatingTestRunnerFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">newTestRunner</span><span style="color: #333333;">(</span>RemoteTestNG6_12<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">66</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ITestRunnerFactory</span><span style="color: #333333;">.</span><span style="color: #0000cc;">newTestRunner</span><span style="color: #333333;">(</span>ITestRunnerFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">52</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunner</span>$ProxyTestRunnerFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">newTestRunner</span><span style="color: #333333;">(</span>SuiteRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">720</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunner</span><span style="color: #333333;">.</span><span style="color: #0000cc;">init</span><span style="color: #333333;">(</span>SuiteRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">224</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunner</span><span style="color: #333333;">.<</span>init<span style="color: #333333;">>(</span>SuiteRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">116</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">createSuiteRunner</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1375</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">createSuiteRunners</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1349</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runSuitesLocally</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1191</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runSuites</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1114</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1082</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">AbstractRemoteTestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span>AbstractRemoteTestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">115</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteTestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">initAndRun</span><span style="color: #333333;">(</span>RemoteTestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">251</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteTestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">main</span><span style="color: #333333;">(</span>RemoteTestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">77</span><span style="color: #333333;">)</span>
</pre></div>
Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-91230171414875012112023-09-21T12:37:00.002+05:302023-09-21T12:37:14.969+05:30How to get currentDate+1day (Tomorrow's date) in m/dd/yyyy format in postman <p>In Postman Tests section write below code. </p><p>const currentDate = new Date();</p><p>currentDate.setDate(currentDate.getDate() + 1);</p><p>const formattedDate = `${currentDate.getMonth() + 1}/${currentDate.getDate()}/${currentDate.getFullYear()}`;</p><p>console.log(formattedDate);</p><p><br /></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhj-La708ggFzaL-qQdBfh2Zis-MLVCGMLcD8KAvPgZ-Z-WS4g50yID4z0gB8wZ1LeTckyTqaGqkjXOUgnSACQs3jQ3ZjThUIe8Cx0WQETMc5Sj2KKHfoFAC7DyJXoxoSNeBoTE1yf_SD3Cd3KXmZaawcnlAxpfY04h9jBGkzD9gZXbyoULMo_K1ghVic3x" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="188" data-original-width="1247" src="https://blogger.googleusercontent.com/img/a/AVvXsEhj-La708ggFzaL-qQdBfh2Zis-MLVCGMLcD8KAvPgZ-Z-WS4g50yID4z0gB8wZ1LeTckyTqaGqkjXOUgnSACQs3jQ3ZjThUIe8Cx0WQETMc5Sj2KKHfoFAC7DyJXoxoSNeBoTE1yf_SD3Cd3KXmZaawcnlAxpfY04h9jBGkzD9gZXbyoULMo_K1ghVic3x=s16000" /></a></div><br /><br /><p></p><div>Example : </div><div><br /></div><div>If today's date is 9/21/2023 then we get 9/22/2023 in the console log.</div><div><br /></div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-18946841967104111812023-08-23T14:56:00.006+05:302023-08-23T14:57:46.433+05:30Workaround fix to specify custom download path for ChromeDriver 114 or Browser 114, Selenium 4.11.0<p>Hi, The following questions and the fix is a work around to download the file to a custom folder in with chrome driver/browser with 114 version </p><p></p><ol style="text-align: left;"><li>Are you getting asked to Save the file while trying to download in Incognito mode? </li><li>Does the file download to "Downloads" folder by default in non incognito mode ? </li><li>Are you seeing in consistent behavior to download a file using ChromeDriver 114 ? </li></ol><p></p><p><br />The work around fix worked for me is to keep the browser in headless mode with <b>--headless=old</b> so the file will download to custom path specified. </p><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white; color: #008800; font-weight: bold;">final</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">static</span><span style="background-color: white;"> String downloadPath </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"C\\Automation\\downloads;</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">HashMap<String, Object> chromePrefs = new HashMap<>();</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">chromePrefs.put("</span><span style="background-color: white;">download</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">default_directory</span><span style="background-color: #fff0f0;">", downloadPath);</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">System.out.println(chromePrefs.get("</span><span style="background-color: white;">download</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">default_directory</span><span style="background-color: #fff0f0;">"));</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">ChromeOptions options = new ChromeOptions();</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">options.setExperimentalOption("</span><span style="background-color: white;">prefs</span><span style="background-color: #fff0f0;">", chromePrefs);</span><span style="background-color: white;">
</span><span style="background-color: #fcff01;"><b><span>options.addArguments("</span><span style="color: #333333;">--</span>headless<span style="color: #333333;">=</span>old</b><b><span>"</span></b><b><span style="color: #333333;">);</span></b></span></pre><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white;">driver</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">set</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> ChromeDriver</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">options</span><span style="background-color: white; color: #333333;">));</span><span style="background-color: white;">
</span></pre></div>
<p> <b>References: </b></p><p><a href="https://stackoverflow.com/questions/76175638/unable-to-change-default-download-directory-for-chrome-selenium-instance-linux">https://stackoverflow.com/questions/76175638/unable-to-change-default-download-directory-for-chrome-selenium-instance-linux</a></p><p><a href="https://github.com/SeleniumHQ/selenium/issues/11637">https://github.com/SeleniumHQ/selenium/issues/11637</a></p>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-76333398768928199642023-07-24T23:55:00.003+05:302023-07-24T23:57:43.278+05:30Batch script to run MS SQL server sql commands<p> Hi, use "sqlcmd" utility in batch script run a set of sql commands/queries through batch script. <br /><br />Make sure to install the following odbc driver and command line utility<br /><a href="http://msodbcsql.msi">msodbcsql.msi</a> and <a href="http://MsSqlCmdLnUtils.msi">MsSqlCmdLnUtils.msi</a></p><div style="text-align: left;"><b>runsql.bat</b></div><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">@<span style="color: #008800; font-weight: bold;">echo</span> <span style="color: #008800; font-weight: bold;">off</span>
sqlcmd -U <span style="background-color: #fff0f0;">"sa"</span> -P <span style="background-color: #fff0f0;">"MyPassword#123"</span> -S <span style="color: #6600ee; font-weight: bold;">11</span>.<span style="color: #6600ee; font-weight: bold;">123</span>.<span style="color: #6600ee; font-weight: bold;">4</span>.<span style="color: #6600ee; font-weight: bold;">56</span> -i <span style="background-color: #fff0f0;">"C:\SQLScripts\CleanUp.sql"</span>
timeout /t <span style="color: #6600ee; font-weight: bold;">5</span> /nobreak
exit
</pre></div><div><br /></div><br /><div><b>CleanUp.sql</b></div>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">use abcDatabase
<span style="color: #008800; font-weight: bold;">delete</span> <span style="color: #008800; font-weight: bold;">from</span> accountTable <span style="color: #008800; font-weight: bold;">where</span> AccountId<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">'123'</span>
</pre></div><br /><div><br /></div><div><span style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;">I hope you find this useful! If you like it, pls do subscribe my </span><a href="https://www.youtube.com/channel/UCNI54-ZwNAjSMknRCfdyRCQ" rel="nofollow" style="background-color: white; color: #4d469c; font-family: Calibri; font-size: 16px; text-decoration-line: none;" target="_blank">YouTube channel</a><span style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;"> for automation or tech updates.</span></div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-89803787384217842592023-07-24T23:06:00.005+05:302023-07-24T23:07:40.583+05:30Batch script to run perl file in linux machine | How to connect to linux in batch script and run perl file<p><span style="background-color: white;"><span style="color: #444444; font-family: Calibri;">To run a perl file placed in linux machine from batch file use "plink" utility of PuTTY in batch scripting. <br /><br />As shown below write batch script and as on execution of batch file in windows machine, the perl will be triggered in linux machine. <br /></span></span></p><p style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;">PuTTY should be installed in the windows(source machine) and plink.exe should be there in the installation folder and it does the job of running perl file in linux machine. </p><div class="separator" style="background-color: white; clear: both; color: #444444; font-family: Calibri; font-size: 16px; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjko5A0kpTRv2tYwIRZrtyySiKp-6y3Wzqe-hoNX8YqWFATb1eFKGwy73pXDcgw7hH7w6fAN1iyHTVps0OmdyxJnHetPr6KYiGJlMkuaSQsLGc1LZ9ShQc_YPccxMTRB3bgNfNLFI27rGYDga1ZRjyytd4Zsn4iM6DowyH7vWWCc0xdZZS1sYQxOEKCMTId/s411/PuTTY.PNG" style="color: #4d469c; margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="322" data-original-width="411" height="251" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjko5A0kpTRv2tYwIRZrtyySiKp-6y3Wzqe-hoNX8YqWFATb1eFKGwy73pXDcgw7hH7w6fAN1iyHTVps0OmdyxJnHetPr6KYiGJlMkuaSQsLGc1LZ9ShQc_YPccxMTRB3bgNfNLFI27rGYDga1ZRjyytd4Zsn4iM6DowyH7vWWCc0xdZZS1sYQxOEKCMTId/s320/PuTTY.PNG" style="background: transparent; border-radius: 0px; border: 1px solid rgb(238, 238, 238); box-shadow: rgba(0, 0, 0, 0.2) 0px 0px 0px; padding: 8px; position: relative;" width="320" /></a></div><p><b>perlexecutioninlinux.bat</b></p>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">@<span style="color: #008800; font-weight: bold;">echo</span> <span style="color: #008800; font-weight: bold;">off</span>
<span style="color: #008800; font-weight: bold;">set</span> <span style="background-color: #fff0f0;">"destinationUser=linuxadmin"</span>
<span style="color: #008800; font-weight: bold;">set</span> <span style="background-color: #fff0f0;">"destinationPassword=MyPassword#123"</span>
<span style="color: #008800; font-weight: bold;">set</span> <span style="background-color: #fff0f0;">"destinationHost=11.123.4.567"</span>
<span style="color: #008800; font-weight: bold;">set</span> <span style="background-color: #fff0f0;">"scriptPath=/home/linuxadmin/AutomationProject/my-perl-file.pl"</span>
plink -pw <span style="color: #996633;">%destinationPassword%</span> -batch <span style="color: #996633;">%destinationUser%</span>@<span style="color: #996633;">%destinationHost%</span> <span style="background-color: #fff0f0;">"perl %scriptPath%"</span>
timeout /t <span style="color: #6600ee; font-weight: bold;">5</span> /nobreak
exit
</pre></div><div><br /></div><div><span style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;">I hope you find this useful! If you like it, pls do subscribe my </span><a href="https://www.youtube.com/channel/UCNI54-ZwNAjSMknRCfdyRCQ" rel="nofollow" style="background-color: white; color: #4d469c; font-family: Calibri; font-size: 16px; text-decoration-line: none;" target="_blank">YouTube channel</a><span style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;"> for automation or tech updates.</span></div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-46129198728556840362023-07-23T02:43:00.005+05:302023-07-24T22:57:36.554+05:30Batch script to copy newman report from windows machine to linux machine<p>To copy newman html report (or in general any file) from windows machine to linux machine use below batch script. </p><p>PuTTY should be installed in the windows(source machine) and pscp.exe should be there in the installation folder and it does the job of copying files from source to destination. </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjko5A0kpTRv2tYwIRZrtyySiKp-6y3Wzqe-hoNX8YqWFATb1eFKGwy73pXDcgw7hH7w6fAN1iyHTVps0OmdyxJnHetPr6KYiGJlMkuaSQsLGc1LZ9ShQc_YPccxMTRB3bgNfNLFI27rGYDga1ZRjyytd4Zsn4iM6DowyH7vWWCc0xdZZS1sYQxOEKCMTId/s411/PuTTY.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="322" data-original-width="411" height="251" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjko5A0kpTRv2tYwIRZrtyySiKp-6y3Wzqe-hoNX8YqWFATb1eFKGwy73pXDcgw7hH7w6fAN1iyHTVps0OmdyxJnHetPr6KYiGJlMkuaSQsLGc1LZ9ShQc_YPccxMTRB3bgNfNLFI27rGYDga1ZRjyytd4Zsn4iM6DowyH7vWWCc0xdZZS1sYQxOEKCMTId/s320/PuTTY.PNG" width="320" /></a></div><br /><p><br /></p>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #888888;">REM linux machine details </span>
@<span style="color: #008800; font-weight: bold;">echo</span> <span style="color: #008800; font-weight: bold;">on</span>
<span style="color: #008800; font-weight: bold;">set</span> <span style="color: #996633;">SOURCE_DIR</span><span style="color: #333333;">=</span>C:\postman\newman\
<span style="color: #008800; font-weight: bold;">set</span> <span style="color: #996633;">USERNAME</span><span style="color: #333333;">=</span>linuxadmin
<span style="color: #008800; font-weight: bold;">set</span> <span style="color: #996633;">PASSWORD</span><span style="color: #333333;">=</span>MyPassword#<span style="color: #6600ee; font-weight: bold;">123</span>
<span style="color: #008800; font-weight: bold;">set</span> <span style="color: #996633;">LINUX_MACHINE_IP</span><span style="color: #333333;">=</span><span style="color: #6600ee; font-weight: bold;">1</span>.<span style="color: #6600ee; font-weight: bold;">123</span>.<span style="color: #6600ee; font-weight: bold;">4</span>.<span style="color: #6600ee; font-weight: bold;">567</span>
<span style="color: #008800; font-weight: bold;">set</span> <span style="color: #996633;">DESTINATION_DIR</span><span style="color: #333333;">=</span>/home/%USERNAME%/AutoDrive
<span style="color: #008800; font-weight: bold;">set</span> <span style="color: #996633;">FILE_PATTERN</span><span style="color: #333333;">=</span>*SmokeTestsNewmanReport.html*
<span style="color: #888888;">REM copy files from windows to linux</span>
pscp -pw <span style="color: #996633;">%PASSWORD%</span> <span style="color: #996633;">%SOURCE_DIR%%FILE_PATTERN%</span> \ <span style="color: #996633;">%USERNAME%</span>@<span style="color: #996633;">%LINUX_MACHINE_IP%</span>:<span style="color: #996633;">%DESTINATION_DIR%</span>
timeout /t <span style="color: #6600ee; font-weight: bold;">15</span> /nobreak
</pre><pre style="line-height: 125%; margin: 0px;">exit</pre></div><div><br /></div><span style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;">I hope you find this useful! If you like it, pls do subscribe my </span><a href="https://www.youtube.com/channel/UCNI54-ZwNAjSMknRCfdyRCQ" rel="nofollow" style="background-color: white; color: #4d469c; font-family: Calibri; font-size: 16px; text-decoration-line: none;" target="_blank">YouTube channel</a><span style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;"> for automation or tech updates.</span>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-16435497039243946172023-07-23T02:31:00.001+05:302023-07-23T02:32:17.591+05:30Batch script to execute newman/postman collection on two different environments by opening two command prompts at a time<p>Hi, batch script below does the following: </p><p>1) Delete newman html extra report if already exists in Reports folder under C drive<br />2) Starts two command prompts in the background and calls the node.js to run the same set of newman/postman smoke tests at a time on two different environments. <br /><br />As two start commands begins execution simultaneously , we need NOT to wait until the first one finishes so can avoid sequential execution and achieve kinda of parallel execution on two different environments with same collection. </p>
<!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white; color: #888888;">REM set the reports path</span><span style="background-color: white;">
@</span><span style="background-color: white; color: #008800; font-weight: bold;">echo</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">on</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">set</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"filePath-1=C:\Reports\SmokeTestReportServer-1.html"</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">set</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"filePath-2=C:\Reports\SmokeTestReportServer-2.html"</span><span style="background-color: white;">
</span><span style="background-color: white; color: #888888;">REM Delete the reports if already exists in Reports folder</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">if</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">exist</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"%filePath-1%"</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">del</span><span style="background-color: white;"> /Q /F </span><span style="background-color: #fff0f0;">"%filePath-1%"</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">if</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">exist</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"%filePath-2%"</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">del</span><span style="background-color: white;"> /Q /F </span><span style="background-color: #fff0f0;">"%filePath-2%"</span><span style="background-color: white;">
</span><span style="background-color: white; color: #888888;">REM Executing Smoke Tests at a time by opening two command prompots for two different servers </span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">echo</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'Server1'</span><span style="background-color: white;">
</span><span style="background-color: #fcff01;">start /B cmd /c <span style="color: #008800; font-weight: bold;">call</span></span><span style="background-color: white;"> newman run </span><span style="background-color: #fff0f0;">"SmokeTests.postman_collection.json"</span><span style="background-color: white;"> -e </span><span style="background-color: #fff0f0;">"Server1Env.postman_environment.json"</span><span style="background-color: white;"> -r htmlextra --reporter-htmlextra-export </span><span style="background-color: #fff0f0;">"C:\Reports\SmokeTestReportServer-1.html"</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">echo</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'Server1 execution is done'</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">echo</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'Server2'</span><span style="background-color: white;">
</span><span style="background-color: #fcff01;">start /B cmd /c <span style="color: #008800; font-weight: bold;">call</span></span><span style="background-color: white;"> newman run </span><span style="background-color: #fff0f0;">"SmokeTests.postman_collection.json"</span><span style="background-color: white;"> -e </span><span style="background-color: #fff0f0;">"Server2Env.postman_environment.json"</span><span style="background-color: white;"> -r htmlextra --reporter-htmlextra-export </span><span style="background-color: #fff0f0;">"C:\Reports\SmokeTestReportServer-2.html"</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">echo</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'Server2 execution is done'</span><span style="background-color: white;">
timeout /t </span><span style="background-color: white; color: #6600ee; font-weight: bold;">3</span><span style="background-color: white;"> /nobreak
exit
</span></pre></div><div><br /></div><div><br /></div><div><b>start:</b> Start a program, command or batch script, opens in a new/separate Command Prompt window.</div><div>More about <b>start </b>command and <b>/B</b> option --> <a href="https://ss64.com/nt/start.html">https://ss64.com/nt/start.html</a></div><div><div>/B Start application without creating a new window. In this case</div><div> Ctrl-C will be ignored - leaving Ctrl-Break as the only way to </div><div> interrupt the application.</div></div><br /><b>cmd:</b> Start a new CMD shell and (optionally) run a command/executable program.<br /><div>More about <b>cmd </b>command and <b>/C</b> option: --> <a href="https://ss64.com/nt/cmd.html">https://ss64.com/nt/cmd.html</a></div><div> /C Run Command and then terminate</div><div><br /></div><div><b>del</b>: Delete one or more files.</div><div>More about <b>del </b>command and <b>/Q /F</b> options --> <a href="https://ss64.com/nt/del.html">https://ss64.com/nt/del.html</a></div><div><div> /F Ignore read-only setting and delete anyway (FORCE) </div><div> /Q Quiet mode, do not give a Yes/No Prompt before deleting.</div></div><div><br /></div><div><span style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;">I hope you find this useful! If you like it, pls do subscribe my </span><a href="https://www.youtube.com/channel/UCNI54-ZwNAjSMknRCfdyRCQ" rel="nofollow" style="background-color: white; color: #4d469c; font-family: Calibri; font-size: 16px; text-decoration-line: none;" target="_blank">YouTube channel</a><span style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;"> for automation or tech updates.</span></div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-44484177931363496692023-07-23T01:55:00.002+05:302023-07-23T01:57:00.783+05:30Replace in postman java script | replace domain name with ip in url and then set as environment variable<p>Let us assume a POST response is returning a URL in header. </p><p>Now, how to replace the DNS name with IP address and set the URL as environment variable ? <br /><br />Below postman java script does the job. </p><p>The first var line(var siteurl) gets the URL from the POST response. <br />The second var line(var ip) gets the IP from environment variable , <br />The third var line(var location) replaces the DNS name with IP and then <br />The fourth var line sets the new URL that is replaced from third line as environment variable(location). </p><!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white; color: #008800; font-weight: bold;">var</span><span style="background-color: white;"> siteurl </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> pm.response.headers.get(</span><span style="background-color: #fff0f0;">"location"</span><span style="background-color: white;">); </span><span style="background-color: white; color: #888888;">// location= https://www.this-is-amazon-site-hostname.com/books</span><span style="background-color: white;">
console.log(</span><span style="background-color: #fff0f0;">"siteurl="</span><span style="background-color: white; color: #333333;">+</span><span style="background-color: white;">siteurl) </span><span style="background-color: white; color: #888888;">// https://www.this-is-amazon-site-hostname.com/books</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">var</span><span style="background-color: white;"> ip </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> pm.environment.get(</span><span style="background-color: #fff0f0;">"serverip"</span><span style="background-color: white;">); </span><span style="background-color: white; color: #888888;">//serverip is the environment variable</span><span style="background-color: white;">
console.log(</span><span style="background-color: #fff0f0;">"Server IP="</span><span style="background-color: white; color: #333333;">+</span><span style="background-color: white;">ip) </span><span style="background-color: white; color: #888888;">// 10.123.4.23</span><span style="background-color: white;">
</span><span style="background-color: #fcff01;"><span style="color: #008800; font-weight: bold;">var</span> location <span style="color: #333333;">=</span> siteurl.replace(<span>"www.this-is-amazon-site-hostname.com"</span>, ip);</span><span style="background-color: white;">
console.log(</span><span style="background-color: #fff0f0;">"location="</span><span style="background-color: white; color: #333333;">+</span><span style="background-color: white;">location) </span><span style="background-color: white; color: #888888;">// https://www.10.123.4.23/books</span><span style="background-color: white;">
</span><span style="background-color: #fcff01;">pm.environment.set(<span>"sitenewurl"</span>,location)</span><span style="background-color: white;"> </span><span style="background-color: white; color: #888888;">//sitenewurl is the environment variable and the value will be set to https://www.10.123.4.23/books</span><span style="background-color: white;">
</span></pre></div><div><br /></div><div><br /></div><br />Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-10567201449262329082023-07-23T00:09:00.001+05:302023-07-23T00:09:19.013+05:30Run newman/postman collection from batch file with html extra report<p>Hi, using "call" command, one can run newman collection from a batch file. This doesn't require to open Node.js command explicitly. </p><p>More about call : </p><p><a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/call">https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/call</a></p><p>Newman installation: <br /><a href="https://learning.postman.com/docs/collections/using-newman-cli/installing-running-newman/">https://learning.postman.com/docs/collections/using-newman-cli/installing-running-newman/</a><br /><br />Html Extra Report: <br /><a href="https://github.com/DannyDainton/newman-reporter-htmlextra">https://github.com/DannyDainton/newman-reporter-htmlextra</a><br /><br />Html Extra Report Extended: <br /><a href="https://www.npmjs.com/package/newman-reporter-htmlextra-extended">https://www.npmjs.com/package/newman-reporter-htmlextra-extended</a></p><p><b>newman-smoke.bat</b></p>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">@<span style="color: #008800; font-weight: bold;">echo</span> <span style="color: #008800; font-weight: bold;">on</span>
<span style="color: #008800; font-weight: bold;">cd</span> C:\PostmanCollections
timeout /t <span style="color: #6600ee; font-weight: bold;">5</span> /nobreak
<span style="color: #008800; font-weight: bold;">call</span> newman run <span style="background-color: #fff0f0;">"SmokeTests.postman_collection.json"</span> -e <span style="background-color: #fff0f0;">"QALabEnv.postman_environment.json"</span> -r htmlextra,cli --reporter-htmlextra-export <span style="background-color: #fff0f0;">"C:\Reports\SmokeTestReport.html"</span> --reporter-htmlextra-title <span style="background-color: #fff0f0;">"Smoke Test Dashboard - QA Lab"</span> --reporter-htmlextra-titleSize <span style="color: #6600ee; font-weight: bold;">6</span>
<span style="color: #008800; font-weight: bold;">echo</span> <span style="background-color: #fff0f0;">'Execution of SmokeTestscollection successful!'</span>
</pre></div><div><br /></div><br /><div><b>-r htmlextra, cli </b><br />This part in the command generates html extra report as well as report output on the console. <br /><br /><pre style="line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"><b>--reporter-htmlextra-title <span style="background-color: #fff0f0;">"Smoke Test Dashboard - QA Lab"
</span></b>This part in the command gives the custom name to the report.
<b> --reporter-htmlextra-titleSize <span style="color: #6600ee;">6</span> </b></pre><pre style="line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;">This part in the command used to specify the size of the report title (1 through 6, 1 is min 6 is max) </pre><br />To redirect the batch logs from console to file add below piece of batch script at the beginning of the file. </div>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">@<span style="color: #008800; font-weight: bold;">echo</span> <span style="color: #008800; font-weight: bold;">off</span>
<span style="color: #008800; font-weight: bold;">set</span> <span style="color: #996633;">LOGFILE</span><span style="color: #333333;">=</span>smoke-log.log
<span style="color: #008800; font-weight: bold;">call</span> <span style="color: #997700; font-weight: bold;">:LOG</span> > <span style="color: #996633;">%LOGFILE%</span>
exit /B
<span style="color: #997700; font-weight: bold;">:LOG</span>
</pre></div><br /><div><span style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;">I hope you find this useful! If you like it, pls do subscribe my </span><a href="https://www.youtube.com/channel/UCNI54-ZwNAjSMknRCfdyRCQ" rel="nofollow" style="background-color: white; color: #4d469c; font-family: Calibri; font-size: 16px; text-decoration-line: none;" target="_blank">YouTube channel</a><span style="background-color: white; color: #444444; font-family: Calibri; font-size: 16px;"> for automation or tech updates.</span></div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-36816068245729063992023-07-22T23:37:00.003+05:302023-07-23T00:09:37.631+05:30Send latest cucumber report as email notification after automation execution<p> Hi, In this blog post, we will see the core concept that worked for us to send cucumber report or extent report as notification after running automation. </p><p>Normally, sending email is done through an SMTP server. This requires username and password details to be provided in the code. To avoid security threats or credentials exposure in the codebase, use perl MIME:Lite ( that is old and not recommended rather there are many alternative utilities such as Email::MIME or MIME::Entity and Email::Sender) utility that doesn't require any credentials( at least password is not required).</p><p>In this example, in order to send extent or cucumber report as automation notification, we use linux machine where perl is running and automation is run through a windows machine. </p><p>In windows, cucumber or extent report will be generated --> copy this report to linux and then perl will take care of sending email with html report as an attachment. </p><p>Copying the jar file to linux, running perl are the two major things that the seleniuum/java code should take care of. And below is how it done. </p><p><a href="https://jasper-bi-suite.blogspot.com/2023/07/perl-script-to-send-html-file-as.html" rel="nofollow" target="_blank">Read this article on how basic perl script can be used to send an html file(in this case the html file is cucumber report or extent report) as an attachment.</a></p><p></p><ul style="text-align: left;"><li>Add jsch dependency to pom.xml </li><li>Write email code in AfterAll hook so always latest report is copied to linux. </li><li>The important part is to write email code in jvm shutdown method that is inside the AfterAll hook </li><li>Create a single session and open two channels, one channel is to copy and the other is to execute perl script that sits in linux. </li></ul><p></p><p><b>jsch dependency</b></p><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #007700;"><dependency></span>
<span style="color: #007700;"><groupId></span>com.jcraft<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>jsch<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>0.1.54<span style="color: #007700;"></version></span>
<span style="color: #007700;"></dependency></span>
</pre></div><div><br /></div><b>
Hooks.java
</b><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">package</span> com<span style="color: #333333;">.</span><span style="color: #0000cc;">email</span><span style="color: #333333;">.</span><span style="color: #0000cc;">common</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.net.InetAddress</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">com.jcraft.jsch.Channel</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">com.jcraft.jsch.ChannelExec</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">com.jcraft.jsch.ChannelSftp</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">com.jcraft.jsch.JSch</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">com.jcraft.jsch.JSchException</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">com.jcraft.jsch.Session</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">com.jcraft.jsch.SftpException</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">com.jcraft.jsch.SftpProgressMonitor</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Hooks</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">final</span> <span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> SftpProgressMonitor monitor <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> SftpProgressMonitor<span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">init</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">final</span> <span style="color: #333399; font-weight: bold;">int</span> op<span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">final</span> String source<span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">final</span> String target<span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">final</span> <span style="color: #333399; font-weight: bold;">long</span> max<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"sftp start uploading file from:"</span> <span style="color: #333333;">+</span> source <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" to:"</span> <span style="color: #333333;">+</span> target<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">boolean</span> <span style="color: #0066bb; font-weight: bold;">count</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">final</span> <span style="color: #333399; font-weight: bold;">long</span> count<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"sftp sending bytes: "</span> <span style="color: #333333;">+</span> count<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">true</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">end</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"sftp uploading is done."</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">};</span>
<span style="color: #555555; font-weight: bold;">@AfterAll</span><span style="color: #333333;">(</span>order <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #888888;">// Cucumber AfterAll hook with order 2</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">putFile</span><span style="color: #333333;">()</span> <span style="color: #008800; font-weight: bold;">throws</span> JSchException<span style="color: #333333;">,</span> SftpException<span style="color: #333333;">,</span> IOException<span style="color: #333333;">,</span> InterruptedException <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"AfterAll - with order=2"</span><span style="color: #333333;">);</span>
InetAddress localhost <span style="color: #333333;">=</span> InetAddress<span style="color: #333333;">.</span><span style="color: #0000cc;">getLocalHost</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"System IP Address : "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>localhost<span style="color: #333333;">.</span><span style="color: #0000cc;">getHostAddress</span><span style="color: #333333;">()).</span><span style="color: #0000cc;">trim</span><span style="color: #333333;">());</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>localhost<span style="color: #333333;">.</span><span style="color: #0000cc;">getHostAddress</span><span style="color: #333333;">().</span><span style="color: #0000cc;">trim</span><span style="color: #333333;">().</span><span style="color: #0000cc;">equals</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"127.0.0.1"</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
Runtime<span style="color: #333333;">.</span><span style="color: #0000cc;">getRuntime</span><span style="color: #333333;">().</span><span style="color: #0000cc;">addShutdownHook</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Thread<span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Runnable<span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">run</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
String FromWindows <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"C:\\Automation\\target\\cucumber-reports\\cucumber-report.html"</span><span style="color: #333333;">;</span>
String ToLinux <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"/home/linuxadmin/AutomationProject/cucumber-report.html"</span><span style="color: #333333;">;</span>
JSch jsch <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> JSch<span style="color: #333333;">();</span>
Session session <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
session <span style="color: #333333;">=</span> jsch<span style="color: #333333;">.</span><span style="color: #0000cc;">getSession</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"linuxadmin"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"12.445.1.999"</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">22</span><span style="color: #333333;">);</span> <span style="color: #888888;">//linux machine</span>
session<span style="color: #333333;">.</span><span style="color: #0000cc;">setConfig</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"StrictHostKeyChecking"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"no"</span><span style="color: #333333;">);</span>
session<span style="color: #333333;">.</span><span style="color: #0000cc;">setPassword</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"MyPassword+@!"</span><span style="color: #333333;">);</span>
session<span style="color: #333333;">.</span><span style="color: #0000cc;">connect</span><span style="color: #333333;">();</span>
Channel channel <span style="color: #333333;">=</span> session<span style="color: #333333;">.</span><span style="color: #0000cc;">openChannel</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"sftp"</span><span style="color: #333333;">);</span>
channel<span style="color: #333333;">.</span><span style="color: #0000cc;">connect</span><span style="color: #333333;">();</span>
ChannelSftp sftpChannel <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>ChannelSftp<span style="color: #333333;">)</span> channel<span style="color: #333333;">;</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Server's home directory: "</span> <span style="color: #333333;">+</span> sftpChannel<span style="color: #333333;">.</span><span style="color: #0000cc;">getHome</span><span style="color: #333333;">());</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
sftpChannel<span style="color: #333333;">.</span><span style="color: #0000cc;">put</span><span style="color: #333333;">(</span>FromWindows<span style="color: #333333;">,</span> ToLinux<span style="color: #333333;">,</span> monitor<span style="color: #333333;">,</span> ChannelSftp<span style="color: #333333;">.</span><span style="color: #0000cc;">OVERWRITE</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>SftpException e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"File is not found in Windows: "</span><span style="color: #333333;">);</span>
e<span style="color: #333333;">.</span><span style="color: #0000cc;">printStackTrace</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
Channel channel2 <span style="color: #333333;">=</span> session<span style="color: #333333;">.</span><span style="color: #0000cc;">openChannel</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"exec"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">((</span>ChannelExec<span style="color: #333333;">)</span> channel2<span style="color: #333333;">).</span><span style="color: #0000cc;">setPty</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">true</span><span style="color: #333333;">);</span>
<span style="color: #333333;">((</span>ChannelExec<span style="color: #333333;">)</span> channel2<span style="color: #333333;">).</span><span style="color: #0000cc;">setCommand</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"perl /home/linuxadmin/AutomationProject/report-notify-email.pl"</span><span style="color: #333333;">);</span>
channel<span style="color: #333333;">.</span><span style="color: #0000cc;">setInputStream</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
<span style="color: #333333;">((</span>ChannelExec<span style="color: #333333;">)</span> channel2<span style="color: #333333;">).</span><span style="color: #0000cc;">setErrStream</span><span style="color: #333333;">(</span>System<span style="color: #333333;">.</span><span style="color: #0000cc;">err</span><span style="color: #333333;">);</span>
InputStream in <span style="color: #333333;">=</span> channel2<span style="color: #333333;">.</span><span style="color: #0000cc;">getInputStream</span><span style="color: #333333;">();</span>
channel2<span style="color: #333333;">.</span><span style="color: #0000cc;">connect</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[]</span> tmp <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> <span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">1024</span><span style="color: #333333;">];</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">true</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(</span>in<span style="color: #333333;">.</span><span style="color: #0000cc;">available</span><span style="color: #333333;">()</span> <span style="color: #333333;">></span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> in<span style="color: #333333;">.</span><span style="color: #0000cc;">read</span><span style="color: #333333;">(</span>tmp<span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">1024</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>i <span style="color: #333333;"><</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">print</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">(</span>tmp<span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">,</span> i<span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>channel2<span style="color: #333333;">.</span><span style="color: #0000cc;">isClosed</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"exit-status: "</span> <span style="color: #333333;">+</span> channel2<span style="color: #333333;">.</span><span style="color: #0000cc;">getExitStatus</span><span style="color: #333333;">());</span>
<span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
Thread<span style="color: #333333;">.</span><span style="color: #0000cc;">sleep</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1000</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>Exception ee<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
sftpChannel<span style="color: #333333;">.</span><span style="color: #0000cc;">exit</span><span style="color: #333333;">();</span>
channel<span style="color: #333333;">.</span><span style="color: #0000cc;">disconnect</span><span style="color: #333333;">();</span>
channel2<span style="color: #333333;">.</span><span style="color: #0000cc;">disconnect</span><span style="color: #333333;">();</span>
session<span style="color: #333333;">.</span><span style="color: #0000cc;">disconnect</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>Exception e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
e<span style="color: #333333;">.</span><span style="color: #0000cc;">printStackTrace</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Shutdown Hook is running !"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Selenium application is terminating ..."</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Skipping sending email from linux server"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><br /><div><br /></div><div>Below code is normally works well but the backdrop is one must provide an email account credentials (username and password). This exposes security issues so to avoid follow aforementioned technique. </div><div><br /></div><div><b>javax.mail dependency</b></div>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #888888;"><!-- https://mvnrepository.com/artifact/javax.mail/mail --></span>
<span style="color: #007700;"><dependency></span>
<span style="color: #007700;"><groupId></span>javax.mail<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>mail<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>1.4.7<span style="color: #007700;"></version></span>
<span style="color: #007700;"></dependency></span>
</pre></div><div><br /></div><br /><!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white; color: #555555; font-weight: bold;">@AfterAll</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">order </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0000dd; font-weight: bold;">1</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;"> </span><span style="background-color: white; color: #888888;">// Cucumber AfterAll hook with order 1</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">static</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333399; font-weight: bold;">void</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0066bb; font-weight: bold;">afterAllEmail</span><span style="background-color: white; color: #333333;">()</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
</span><span style="background-color: #f4cccc;"> <span style="color: #008800; font-weight: bold;">final</span> String username <span style="color: #333333;">=</span> <span>"sadakar@email.com"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">final</span> String password <span style="color: #333333;">=</span> <span>"MyPassword#12!"</span><span style="color: #333333;">;</span></span><span style="background-color: white;">
Properties props </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> Properties</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;">
props</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">put</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"mail.smtp.auth"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">true</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
props</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">put</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"mail.smtp.starttls.enable"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">true</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
props</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">put</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"mail.smtp.starttls.required"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">true</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
props</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">put</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"mail.smtp.host"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: #fff0f0;">"smtp.office365.com"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
props</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">put</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"mail.smtp.ssl.trust"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"smtp.office365.com"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
props</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">put</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"mail.smtp.port"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: #fff0f0;">"587"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
props</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">put</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"mail.debug"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"true"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
props</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">put</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"mail.smtp.ssl.protocols"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"TLSv1.2"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
Session session </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> Session</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">getInstance</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">props</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> javax</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">mail</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">Authenticator</span><span style="background-color: white; color: #333333;">()</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">protected</span><span style="background-color: white;"> PasswordAuthentication </span><span style="background-color: white; color: #0066bb; font-weight: bold;">getPasswordAuthentication</span><span style="background-color: white; color: #333333;">()</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">return</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;">
PasswordAuthentication</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">username</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> password</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">});</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">try</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
Message message </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> MimeMessage</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">session</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
message</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">setFrom</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> InternetAddress</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"sadakar@email.com"</span><span style="background-color: white; color: #333333;">));</span><span style="background-color: white;">
message</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">setRecipients</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">Message</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">RecipientType</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">TO</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> InternetAddress</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">parse</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"toemail@email.com"</span><span style="background-color: white; color: #333333;">));</span><span style="background-color: white;">
message</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">setSubject</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"UI Automation Report"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
message</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">setText</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"Please refer to the AutomationExtentOrSparkReport.html for the test results"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
MimeBodyPart messageBodyPart </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> MimeBodyPart</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;">
Multipart multipart </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> MimeMultipart</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;">
messageBodyPart </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> MimeBodyPart</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;"> String automationReportPath </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">getProperty</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"user.dir"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"Spark Report File Path="</span><span style="background-color: white; color: #333333;">+</span><span style="background-color: white;">automationReportPath</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
String file </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> automationReportPath</span><span style="background-color: white; color: #333333;">+</span><span style="background-color: #fff0f0;">"//target//ExtentReport//AutomationExtentOrSparkReport.html"</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
String fileName </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"AutomationExtentOrSparkReport.html"</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
DataSource source </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> FileDataSource</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">file</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
messageBodyPart</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">setDataHandler</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> DataHandler</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">source</span><span style="background-color: white; color: #333333;">));</span><span style="background-color: white;">
messageBodyPart</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">setFileName</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">fileName</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
multipart</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">addBodyPart</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">messageBodyPart</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
message</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">setContent</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">multipart</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"Sending"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
Transport</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">send</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">message</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"Done"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">catch</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">MessagingException e</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;"> e</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">printStackTrace</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"Email hook ending"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span></pre></div><div><br /></div>
I hope you find this useful! If you like it, pls do subscribe my <a href="https://www.youtube.com/channel/UCNI54-ZwNAjSMknRCfdyRCQ" rel="nofollow" target="_blank">YouTube channel</a> for automation or tech updates.Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-68009753895501843302023-07-22T22:16:00.002+05:302023-07-22T22:16:24.035+05:30Perl script to send html file as an attachment in email | How to send cucumber report or newman html extra report as a notification after automation run with dummy email<div>Below Perl script with MIME::Lite utility in Cents OS is does the job of sending an email with html attachment. This is one of the basic techniques used to send an automation report after execution with out providing actual user email or password. </div><div><br /></div><div>1) Should have Cent OS </div><div>2) Should be installed MIME:Lite utility </div><div><br /></div><div><b>References: </b></div><div><a href="https://metacpan.org/pod/MIME::Lite">https://metacpan.org/pod/MIME::Lite</a><br /> </div><div><br /></div><div><b>Perl file name: </b>cucumber-report-email-notification.pl</div><div><b><br /></b></div><div><b>Perl file execution : </b></div><div><b style="background-color: #fcff01;">perl cucumber-report-email-notification.pl</b></div><div><br /></div><div><!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white; color: #888888;">#Author: Sadakar Pochampalli</span><span style="background-color: white;">
</span><span style="background-color: white; color: #888888;">#use strict;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">use</span><span style="background-color: white;"> warnings;
</span><span style="background-color: white; color: #008800; font-weight: bold;">use</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">MIME::</span><span style="background-color: white;">Lite;
</span><span style="background-color: white; color: #008800; font-weight: bold;">my</span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$to</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'ABCProjectTeam@email.com'</span><span style="background-color: white;">;
</span><span style="background-color: white; color: #008800; font-weight: bold;">my</span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$cc</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'test@email.com'</span><span style="background-color: white;">;
</span><span style="background-color: white; color: #008800; font-weight: bold;">my</span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$bcc</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: #fff0f0;">'test2@email.com'</span><span style="background-color: white;">;
</span><span style="background-color: white; color: #008800; font-weight: bold;">my</span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$from</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'AutomationTeam@email.com'</span><span style="background-color: white;">;
</span><span style="background-color: white; color: #008800; font-weight: bold;">my</span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$subject</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"Regression Testing Results"</span><span style="background-color: white;">;
</span><span style="background-color: white; color: #008800; font-weight: bold;">my</span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$message</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"<p>Hi, <br>Test Project Automation Report</p> <br>Thank you <br> Testing Team"</span><span style="background-color: white;">;
</span><span style="background-color: white; color: #008800; font-weight: bold;">my</span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$msg</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">MIME::</span><span style="background-color: white;">Lite</span><span style="background-color: white; color: #333333;">-></span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;">(
From </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$from</span><span style="background-color: white;">,
To </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$to</span><span style="background-color: white;">,
Cc </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$cc</span><span style="background-color: white;">,
Subject </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$subject</span><span style="background-color: white;">,
Type </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'multipart/related'</span><span style="background-color: white;">
);
</span><span style="background-color: white; color: #996633;">$msg</span><span style="background-color: white; color: #333333;">-></span><span style="background-color: white;">attach(
Type </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'TEXT/html'</span><span style="background-color: white;">,
Data </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: white; color: #996633;">$message</span><span style="background-color: white;">
);
</span><span style="background-color: white; color: #996633;">$msg</span><span style="background-color: white; color: #333333;">-></span><span style="background-color: white;">attach(
Type </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'image/text'</span><span style="background-color: white;">,
Path </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'/home/sadakar/AutomationProject/sadakar-logo.jpg'</span><span style="background-color: white;">,
Filename </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'sadakar.jpg'</span><span style="background-color: white;">,
Disposition </span><span style="background-color: white; color: #333333;">=></span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">'attachment'</span><span style="background-color: white;">
);
</span><span style="background-color: #fcff01;"><span style="color: #996633;">$msg</span><span style="color: #333333;">-></span>attach(
Type <span style="color: #333333;">=></span> <span>'file'</span>,
Path <span style="color: #333333;">=></span> <span>'/home/sadakar/AutomationProject/RegressionTests.html'</span>,
Filename <span style="color: #333333;">=></span> <span>'RegressionTests.html'</span>,
Disposition <span style="color: #333333;">=></span> <span>'attachment'</span>
);</span><span style="background-color: white;">
</span><span style="background-color: white; color: #996633;">$msg</span><span style="background-color: white; color: #333333;">-></span><span style="background-color: white; color: #007020;">send</span><span style="background-color: white;">;
</span><span style="background-color: white; color: #008800; font-weight: bold;">print</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"Email Sent\n"</span><span style="background-color: white;">;
</span></pre></div><br /><br /></div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-45278428879057449462023-06-20T02:36:00.001+05:302023-06-20T02:36:23.107+05:30java.lang.NoSuchMethodError: 'void org.testng.TestRunner.(org.testng.internal.IConfiguration, org.testng.ISuite, org.testng.xml.XmlTest, boolean, java.util.Collection, java.util.List)'The following worked for me with the dependencies mentioned in pom.xml <br /><br /><span style="background-color: #fcff01;"><b>If you are on 7.8.0 TestNG downgrade it to 7.7.0</b></span><div><span style="background-color: #fcff01;"><b>or </b></span></div><div><span style="background-color: #fcff01;"><b>do not take testng dependency rather take cucumber-testng and cucumber-java both versioned 7.12.0</b></span></div><div><br /></div><div><b>Eclipse console log:</b></div>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #333333;">[</span>RemoteTestNG<span style="color: #333333;">]</span> detected TestNG version <span style="color: #6600ee; font-weight: bold;">7.8</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Failed to load <span style="color: #008800; font-weight: bold;">class</span> <span style="background-color: #ffaaaa; color: red;">"</span><span style="color: #bb0066; font-weight: bold;">org</span><span style="color: #333333;">.</span><span style="color: #0000cc;">slf4j</span><span style="color: #333333;">.</span><span style="color: #0000cc;">impl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">StaticLoggerBinder</span><span style="background-color: #ffaaaa; color: red;">"</span><span style="color: #333333;">.</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Defaulting to no<span style="color: #333333;">-</span>operation <span style="color: #333333;">(</span>NOP<span style="color: #333333;">)</span> logger implementation
<span style="color: #997700; font-weight: bold;">SLF4J:</span> See <span style="color: #997700; font-weight: bold;">http:</span><span style="color: #888888;">//www.slf4j.org/codes.html#StaticLoggerBinder for further details.</span>
java<span style="color: #333333;">.</span><span style="color: #0000cc;">lang</span><span style="color: #333333;">.</span><span style="color: #0000cc;">NoSuchMethodError</span><span style="color: #333333;">:</span> <span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333399; font-weight: bold;">void</span> org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestRunner</span><span style="color: #333333;">.<</span>init<span style="color: #333333;">>(</span>org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">IConfiguration</span><span style="color: #333333;">,</span> org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ISuite</span><span style="color: #333333;">,</span> org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">xml</span><span style="color: #333333;">.</span><span style="color: #0000cc;">XmlTest</span><span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">boolean</span><span style="color: #333333;">,</span> java<span style="color: #333333;">.</span><span style="color: #0000cc;">util</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Collection</span><span style="color: #333333;">,</span> java<span style="color: #333333;">.</span><span style="color: #0000cc;">util</span><span style="color: #333333;">.</span><span style="color: #0000cc;">List</span><span style="color: #333333;">)</span><span style="background-color: #ffaaaa; color: red;">'</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">support</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteTestNG6_12</span>$1<span style="color: #333333;">.</span><span style="color: #0000cc;">newTestRunner</span><span style="color: #333333;">(</span>RemoteTestNG6_12<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">33</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">support</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteTestNG6_12</span>$DelegatingTestRunnerFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">newTestRunner</span><span style="color: #333333;">(</span>RemoteTestNG6_12<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">66</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ITestRunnerFactory</span><span style="color: #333333;">.</span><span style="color: #0000cc;">newTestRunner</span><span style="color: #333333;">(</span>ITestRunnerFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">52</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunner</span>$ProxyTestRunnerFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">newTestRunner</span><span style="color: #333333;">(</span>SuiteRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">720</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunner</span><span style="color: #333333;">.</span><span style="color: #0000cc;">init</span><span style="color: #333333;">(</span>SuiteRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">224</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunner</span><span style="color: #333333;">.<</span>init<span style="color: #333333;">>(</span>SuiteRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">116</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">createSuiteRunner</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1375</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">createSuiteRunners</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1349</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runSuitesLocally</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1191</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runSuites</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1114</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1082</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">AbstractRemoteTestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span>AbstractRemoteTestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">115</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteTestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">initAndRun</span><span style="color: #333333;">(</span>RemoteTestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">251</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteTestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">main</span><span style="color: #333333;">(</span>RemoteTestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">77</span><span style="color: #333333;">)</span>
</pre></div><br /><b> pom.xml
</b><!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white; color: #007700;"><project</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://maven.apache.org/POM/4.0.0"</span><span style="background-color: white;">
</span><span style="background-color: white; color: #0000cc;">xmlns:xsi=</span><span style="background-color: #fff0f0;">"http://www.w3.org/2001/XMLSchema-instance"</span><span style="background-color: white;">
</span><span style="background-color: white; color: #0000cc;">xsi:schemaLocation=</span><span style="background-color: #fff0f0;">"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"</span><span style="background-color: white; color: #007700;">></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><modelVersion></span><span style="background-color: white;">4.0.0</span><span style="background-color: white; color: #007700;"></modelVersion></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><groupId></span><span style="background-color: white;">CucumberParallelExecutionTestNG</span><span style="background-color: white; color: #007700;"></groupId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><artifactId></span><span style="background-color: white;">CucumberParallelExecutionTestNG</span><span style="background-color: white; color: #007700;"></artifactId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><version></span><span style="background-color: white;">0.0.1-SNAPSHOT</span><span style="background-color: white; color: #007700;"></version></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><name></span><span style="background-color: white;">CucumberParallelExecutionTestNG</span><span style="background-color: white; color: #007700;"></name></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><description></span><span style="background-color: white;">CucumberParallelExecutionTestNG</span><span style="background-color: white; color: #007700;"></description></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><dependencies></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><groupId></span><span style="background-color: white;">io.cucumber</span><span style="background-color: white; color: #007700;"></groupId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><artifactId></span><span style="background-color: white;">cucumber-java</span><span style="background-color: white; color: #007700;"></artifactId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><version></span><span style="background-color: white;">7.12.0</span><span style="background-color: white; color: #007700;"></version></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #888888;"><!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java --></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><groupId></span><span style="background-color: white;">io.cucumber</span><span style="background-color: white; color: #007700;"></groupId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><artifactId></span><span style="background-color: white;">cucumber-testng</span><span style="background-color: white; color: #007700;"></artifactId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><version></span><span style="background-color: white;">7.12.0</span><span style="background-color: white; color: #007700;"></version></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><groupId></span><span style="background-color: white;">org.seleniumhq.selenium</span><span style="background-color: white; color: #007700;"></groupId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><artifactId></span><span style="background-color: white;">selenium-java</span><span style="background-color: white; color: #007700;"></artifactId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><version></span><span style="background-color: white;">4.10.0</span><span style="background-color: white; color: #007700;"></version></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></dependency></span></pre><pre style="line-height: 125%; margin: 0px;"><br /></pre><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white;"><span> </span><span> </span><span> </span><span> <!-- Comment testng dependency since pom already has cucumber-testng or
</span> you could enable the dependency with downgraded version 7.7.0
<span> </span><span> </span><span> </span><span> --></span>
</span><span style="background-color: #fcff01;"><span style="color: #888888;"><!-- https://mvnrepository.com/artifact/org.testng/testng --></span>
<span style="color: #888888;"><!-- <dependency></span>
<span style="color: #888888;"> <groupId>org.testng</groupId></span>
<span style="color: #888888;"> <artifactId>testng</artifactId></span>
<span style="color: #888888;"> <version>7.8.0</version></span>
<span style="color: #888888;"> </dependency></span>
<span style="color: #888888;"> --></span></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><groupId></span><span style="background-color: white;">tech.grasshopper</span><span style="background-color: white; color: #007700;"></groupId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><artifactId></span><span style="background-color: white;">extentreports-cucumber7-adapter</span><span style="background-color: white; color: #007700;"></artifactId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><version></span><span style="background-color: white;">1.2.0</span><span style="background-color: white; color: #007700;"></version></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><groupId></span><span style="background-color: white;">org.projectlombok</span><span style="background-color: white; color: #007700;"></groupId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><artifactId></span><span style="background-color: white;">lombok</span><span style="background-color: white; color: #007700;"></artifactId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><version></span><span style="background-color: white;">1.18.24</span><span style="background-color: white; color: #007700;"></version></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><scope></span><span style="background-color: white;">provided</span><span style="background-color: white; color: #007700;"></scope></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #888888;"><!-- https://mvnrepository.com/artifact/javax.mail/mail --></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><groupId></span><span style="background-color: white;">javax.mail</span><span style="background-color: white; color: #007700;"></groupId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><artifactId></span><span style="background-color: white;">mail</span><span style="background-color: white; color: #007700;"></artifactId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><version></span><span style="background-color: white;">1.4.7</span><span style="background-color: white; color: #007700;"></version></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></dependency></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></dependencies></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><build></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><pluginManagement></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><plugins></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><plugin></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><groupId></span><span style="background-color: white;">org.apache.maven.plugins</span><span style="background-color: white; color: #007700;"></groupId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><artifactId></span><span style="background-color: white;">maven-surefire-plugin</span><span style="background-color: white; color: #007700;"></artifactId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><version></span><span style="background-color: white;">3.1.2</span><span style="background-color: white; color: #007700;"></version></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><configuration></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><suiteXmlFiles></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><suiteXmlFile></span><span style="background-color: white;">testng.xml</span><span style="background-color: white; color: #007700;"></suiteXmlFile></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></suiteXmlFiles></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></configuration></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></plugin></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><plugin></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><groupId></span><span style="background-color: white;">org.apache.maven.plugins</span><span style="background-color: white; color: #007700;"></groupId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><artifactId></span><span style="background-color: white;">maven-compiler-plugin</span><span style="background-color: white; color: #007700;"></artifactId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><version></span><span style="background-color: white;">3.11.0</span><span style="background-color: white; color: #007700;"></version></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><configuration></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><source></span><span style="background-color: white;">17</span><span style="background-color: white; color: #007700;"></source></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><target></span><span style="background-color: white;">17</span><span style="background-color: white; color: #007700;"></target></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></configuration></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></plugin></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><plugin></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><groupId></span><span style="background-color: white;">org.apache.maven.plugins</span><span style="background-color: white; color: #007700;"></groupId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><artifactId></span><span style="background-color: white;">maven-assembly-plugin</span><span style="background-color: white; color: #007700;"></artifactId></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><version></span><span style="background-color: white;">3.1.1</span><span style="background-color: white; color: #007700;"></version></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><configuration></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><archive></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><manifest></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><addClasspath></span><span style="background-color: white;">true</span><span style="background-color: white; color: #007700;"></addClasspath></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><mainClass></span><span style="background-color: white;">runners.CucumberRunnerCLI</span><span style="background-color: white; color: #007700;"></mainClass></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></manifest></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><manifestEntries></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><Class-Path></span><span style="background-color: white;">.</span><span style="background-color: white; color: #007700;"></Class-Path></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></manifestEntries></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></archive></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><descriptorRefs></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><descriptorRef></span><span style="background-color: white;">jar-with-dependencies</span><span style="background-color: white; color: #007700;"></descriptorRef></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></descriptorRefs></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></configuration></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><executions></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><execution></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><id></span><span style="background-color: white;">make-assembly</span><span style="background-color: white; color: #007700;"></id></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><phase></span><span style="background-color: white;">package</span><span style="background-color: white; color: #007700;"></phase></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><goals></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"><goal></span><span style="background-color: white;">single</span><span style="background-color: white; color: #007700;"></goal></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></goals></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></execution></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></executions></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></plugin></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></plugins></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></pluginManagement></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></build></span><span style="background-color: white;">
</span><span style="background-color: white; color: #007700;"></project></span><span style="background-color: white;">
</span></pre></div>
Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-60268271105459123922023-06-11T01:52:00.005+05:302023-07-22T22:17:10.933+05:30Usage of JVM addShutdownHook in cucumber automation to send latest cucumber or extent reports in email<p>Hi, In this post, we can see how to use JVM shut down hook with in cucumber Hooks. </p><p><b>What is JVM shut down hook ? <br /><i>(Definition credits : <a href="http://geeksforgeeks.org">geeksforgeeks.org</a>)</i></b><br />A special construct that facilitates the developers to add some code that has to be run when the<br />Java Virtual Machine (JVM) is shutting down is known as the Java shutdown hook. </p><p><br /><b>Begin with some interesting questions ! </b><br />1) Did you ever think of refreshing a folder in java coding to send latest run cucumber report or <br /> extent report ? <br />2) Did you keep your email notification code in cucumber After or AfterAll hook and tried <br /> sending email but ended-up with old report in mail inbox ? <br />3) How did you solve this problem with Cucumber, TestNG integration ? <br /><br />Perhaps! There might be other solutions and could be better ones. <br />My approach was, effectively make use of JVM shut down hook with in cucumber AfterAll hook to have the latest run report attached and sent over the email. <br /><br />It started with, <br /><b>What is cucumber AfterAll hook ? </b><br /></p><p>AfterAll is a cucumber hook that run after all scenarios have been executed.</p><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #555555; font-weight: bold;">@AfterAll</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">afterAll</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// Runs after all scenarios</span>
<span style="color: #333333;">}</span></pre></div><p><b>JVM Shutdown hook basic example: </b><br />In the below program, there are two print statements.<br /><br />By using addShutdownHook JVM would print <i>"This text prints before shutdown!"</i> firstly and at the time JVM shut down it prints <i>"Shutdown Hook is running and this prints at last!"</i><br /><br />That is, statements inside run() method executes at the very end. </p><!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">class</span><span style="background-color: white;"> </span><span style="background-color: white; color: #bb0066; font-weight: bold;">ShutDownHook</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">static</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333399; font-weight: bold;">void</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0066bb; font-weight: bold;">main</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">String</span><span style="background-color: white; color: #333333;">[]</span><span style="background-color: white;"> args</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
</span><span style="background-color: #fcff01;">Runtime<span style="color: #333333;">.</span><span style="color: #0000cc;">getRuntime</span><span style="color: #333333;">().</span><span style="color: #0000cc;">addShutdownHook</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Thread<span style="color: #333333;">()</span>
<span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">run</span><span style="color: #333333;">()</span>
<span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span>"Shutdown Hook is running and this prints at last!"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">});</span></span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"This text prints before shutdown!"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span></pre></div>
<p>Below is the combined implementation of @AfterAll cucumber hook and JVM addShutdownHook. <br />In the run() method, keep the email triggering code so the selenium execution always picks the latest report to be sent in the mail. It pretty much worked through jar execution too. <br /></p>
<!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white; color: #008800; font-weight: bold;">package</span><span style="background-color: white;"> parallel</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">java.net.InetAddress</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">java.net.UnknownHostException</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">io.cucumber.java.After</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">io.cucumber.java.AfterAll</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">io.cucumber.java.Before</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">io.cucumber.java.Scenario</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">class</span><span style="background-color: white;"> </span><span style="background-color: white; color: #bb0066; font-weight: bold;">Hooks</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
</span><span style="background-color: white; color: #555555; font-weight: bold;">@Before</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">order </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0000dd; font-weight: bold;">0</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333399; font-weight: bold;">void</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0066bb; font-weight: bold;">before</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">Scenario scenaio</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">throws</span><span style="background-color: white;"> Exception </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
DriverFactory</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">setDriver</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"Current Thread Name:"</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">+</span><span style="background-color: white;"> Thread</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">currentThread</span><span style="background-color: white; color: #333333;">().</span><span style="background-color: white; color: #0000cc;">getName</span><span style="background-color: white; color: #333333;">());</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"Current Thread ID:"</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">+</span><span style="background-color: white;"> Thread</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">currentThread</span><span style="background-color: white; color: #333333;">().</span><span style="background-color: white; color: #0000cc;">getId</span><span style="background-color: white; color: #333333;">());</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span><span style="background-color: white; color: #555555; font-weight: bold;">@After</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">order </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0000dd; font-weight: bold;">0</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333399; font-weight: bold;">void</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0066bb; font-weight: bold;">after</span><span style="background-color: white; color: #333333;">()</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">throws</span><span style="background-color: white;"> Exception </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
DriverFactory</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">closeDriver</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span><span style="background-color: white; color: #555555; font-weight: bold;">@AfterAll</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">order </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0000dd; font-weight: bold;">0</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">static</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333399; font-weight: bold;">void</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0066bb; font-weight: bold;">afterAll</span><span style="background-color: white; color: #333333;">()</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">throws</span><span style="background-color: white;"> UnknownHostException </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"AfterAll - with order=0"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
InetAddress localhost </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> InetAddress</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">getLocalHost</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"System IP Address : "</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">+</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">localhost</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">getHostAddress</span><span style="background-color: white; color: #333333;">()).</span><span style="background-color: white; color: #0000cc;">trim</span><span style="background-color: white; color: #333333;">());</span><span style="background-color: white;">
</span><span style="background-color: #fcff01;"> Runtime<span style="color: #333333;">.</span><span style="color: #0000cc;">getRuntime</span><span style="color: #333333;">().</span><span style="color: #0000cc;">addShutdownHook</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Thread<span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Runnable<span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">run</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span>"Shutdown Hook is running and this text prints before JVM shut downs!"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span>"This text prints before Shutdown hook"</span><span style="color: #333333;">);</span></span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span></pre></div><div><br /></div><div><br /></div><b>Eclipse logs: </b><br /><!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white;">[RemoteTestNG] detected TestNG version 7.7.0
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
@LoginFeature @ForgotPassword
Scenario: Forgot password link verification # parallel/Login.feature:16
@LoginFeature @Login
Scenario: Login to Orange HRM # parallel/Login.feature:9
Jun 11, 2023 1:01:23 AM org.openqa.selenium.remote.service.DriverService$Builder getLogOutput
INFO: Driver logs no longer sent to console by default; https://www.selenium.dev/documentation/webdriver/drivers/service/#setting-log-output
Jun 11, 2023 1:01:23 AM org.openqa.selenium.remote.service.DriverService$Builder getLogOutput
INFO: Driver logs no longer sent to console by default; https://www.selenium.dev/documentation/webdriver/drivers/service/#setting-log-output
Current Thread Name:TestNG-PoolService-0
Current Thread ID:16
Current Thread Name:TestNG-PoolService-1
Current Thread ID:17
Given User is on login page # parallel.LoginStepDef.user_is_on_login_page()
When User enters username "Admin" # parallel.LoginStepDef.user_enters_username(java.lang.String)
Given User is on login page # parallel.LoginStepDef.user_is_on_login_page()
Then User verifies Forgot password link display # parallel.LoginStepDef.user_verifies_forgot_password_link_display()
And User enters password "Admin123" # parallel.LoginStepDef.user_enters_password(java.lang.String)
And User clicks on Login button # parallel.LoginStepDef.user_clicks_on_login_button()
Navigation to home page
Then User should navigate to Orange HRM home page # parallel.LoginStepDef.user_should_navigate_to_orange_hrm_home_page()
AfterAll - with order=0
System IP Address : 192.168.1.8
</span><span style="background-color: #fcff01;">This text prints before Shutdown hook</span><span style="background-color: white;">
┌──────────────────────────────────────────────────────────────────────────┐
│ View your Cucumber Report at: │
│ https://reports.cucumber.io/reports/213e45d0-8053-4753-b2c4-78f40d98bd71 │
│ │
│ This report will self-destruct in 24h. │
│ Keep reports forever: https://reports.cucumber.io/profile │
└──────────────────────────────────────────────────────────────────────────┘PASSED: io.cucumber.testng.AbstractTestNGCucumberTests.runScenario("Login to Orange HRM", "Login page validations")
Runs Cucumber Scenarios
PASSED: io.cucumber.testng.AbstractTestNGCucumberTests.runScenario("Forgot password link verification", "Login page validations")
Runs Cucumber Scenarios
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 2, Passes: 2, Failures: 0, Skips: 0
===============================================
</span><span style="background-color: #fcff01;">Shutdown Hook is running and this text prints before JVM shut downs!</span><span style="background-color: white;">
</span></pre></div><br />I hope this helped you a bit! If you like it, please do Subscribe my <a href="https://www.youtube.com/watch?v=IkrXOkkDG5c&feature=youtu.be" rel="nofollow" target="_blank">YouTube</a> channel for interesting updates. Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-52093486363629887662023-06-11T00:12:00.471+05:302023-06-20T02:20:38.876+05:30Cucumber scenarios parallel execution with ThreadLocal driver and dynamic dataproviderthreadcount | TestNG, Java Selenium, Maven , POM page factory Hi, In this post, we will see how to run cucumber scenarios in parallel with TestNG. <br /><br /><b>What is parallel testing in cucumber? </b><br />Parallel testing in Cucumber refers to the ability to execute Cucumber scenarios in parallel, allowing multiple scenarios to run simultaneously and speeding up the overall test execution time.<br /><br />Consider below factors while implementing parallel execution. <br /><div><ul style="text-align: left;"><li>Scenario Independence</li><li>Thread Safety</li><li>Tagging Scenarios</li><li>Synchronization</li></ul></div><br /><b>Software : </b><br />Java : "17.0.7" 2023-04-18 LTS (java -version)<br />Maven : Apache Maven 3.9.2 (mvn -version)<div>Chrome browser: 114.0.5735.110 (Official Build) (64-bit)<br />Chrome WebDriver: 114.0.5735.90<br /><a href="https://chromedriver.storage.googleapis.com/index.html?path=114.0.5735.90/">https://chromedriver.storage.googleapis.com/index.html?path=114.0.5735.90/</a><br /><br />cucumber-java 7.12.0<br />cucumber-testng 7.12.0<br />selenium-java 4.10.0<br />maven-surefire-plugin 3.1.2<br />maven-compiler-plugin 3.11.0<br /><br /><b>Example: </b>Execute two scenarios in parallel from a single feature file. <br />i.e., <br />1) Verify user is able to login to the application with valid credentials <br />2) Verify Forgot password link is displayed on login page. <br /><br /><b>Is it necessary to have testng.xml for parallel execution ? <br /></b>There could be different approaches to perform parallel execution from command line or jar file or from CI/CD method, in this demo I'd say yes it is necessary to have testng.xml so that we can pass dynamic thread count. <br /><br /><b>What is ThreadLocal webdriver in cucumber ? Why it is important ?</b><br /><div>A ThreadLocal webdriver refers to an instance of a WebDriver object that is stored in a ThreadLocal variable. </div><div>Each thread running a Cucumber scenario or step can have its own WebDriver instance, isolated from other threads.</div><div>This approach ensures thread safety and prevents conflicts when executing scenarios in parallel.<br /><br /><b>Here's why ThreadLocal webdriver is important</b><br /><div><ul style="text-align: left;"><li>Thread Safety</li><li>Parallel Execution</li><li>Resource Management</li><li>Scenario Isolation</li></ul></div></div><b>The project folder structure: <br />Is mandatory to keep all the code in "parallel" folder as in many example over the internet ? </b><br />No, it is not necessary to keep them in "parallel" folder. Similarly to keep the features NO "parallel" folder is required. <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgWPZSYzK54VJgMqd0JFNh94eXfvcSOBEO0mz6QJEALpOlcblr1NZanRzEs07EBBmtapptqZ1GlO91rh1Z1AcSSxYVi_iQQj7E29EXWDtam5B6iLTFW_qNkFpTl-OJu11U2Ga3VZoPm9WoL6C9UuhdrUp-XLGnN0CSn1Klv7T9X6BqTFiobzdSuwr6tA9U4" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="481" data-original-width="255" src="https://blogger.googleusercontent.com/img/a/AVvXsEgWPZSYzK54VJgMqd0JFNh94eXfvcSOBEO0mz6QJEALpOlcblr1NZanRzEs07EBBmtapptqZ1GlO91rh1Z1AcSSxYVi_iQQj7E29EXWDtam5B6iLTFW_qNkFpTl-OJu11U2Ga3VZoPm9WoL6C9UuhdrUp-XLGnN0CSn1Klv7T9X6BqTFiobzdSuwr6tA9U4=s16000" /></a></div><b>Concepts covered in code base:</b><br /><ul style="text-align: left;"><li>DriverFactory for chrome and edge - How to pass chrome or edge as command line argument ? </li><li>Parallel execution configurations - Where and how to configure parallel execution with TestNG? </li><li>POM model with page factory pattern - How to isolate locators and step definitions ? </li><li>Cucumber hooks - What is the recommendation of cucumber hooks over TestNG hooks ? </li><li>Reports </li><ul><li>Which report is to be used - cucumber reports or extent reports ? cucumber reports </li><li>Where to write email code to send the latest reports ? In JVM shutdown hook that is written in cucumber AfterAll hook<br />(Did you ever try to remove or refresh a folder to have the latest reports to be sent over email)</li></ul><li>How to run the project ?</li><ul><li>Through command line </li><li>Through eclipse run as TestNG</li><li>Through executable jar file</li></ul></ul><div><b>Would you like to watch few mins demo in a no voice video ? </b><br /><br /></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/QXyKc21S1_0" width="436" youtube-src-id="QXyKc21S1_0"></iframe></div><div>Jumping on to the core of this article i.e., parallel testing <br /><br /><b><u>Parallel execution configurations: <br /></u><br />(For complete code download project from <a href="https://github.com/sadakar/CucumberParallelTestThreadLocalDynamicThreadCount.git" rel="nofollow" target="_blank">GitHub</a> or Use this link to <a href="https://drive.google.com/file/d/1sAb3BTtoUusGNORJeyBksQq_KmkMIsmw/view?usp=sharing" rel="nofollow" target="_blank">download as Zip</a>) </b><br /><ul style="text-align: left;"><li>Declare thread local driver in WebDriverFactory java class and then set, get and remove instances of the driver. <br /><br /><div style="background-color: white; padding: 0px 0px 0px 2px;"><div style="font-family: Consolas; font-size: 10pt; white-space: pre;"><p style="background-color: #e8f2fe; margin: 0px;"><span style="color: #7f0055; font-weight: bold;">private</span> <span style="color: #7f0055; font-weight: bold;">static</span> ThreadLocal<WebDriver> <span style="color: #0000c0; font-style: italic;">driver</span> = <span style="color: #7f0055; font-weight: bold;">new</span> ThreadLocal<>();</p></div></div></li></ul><ul style="text-align: left;"><li>Override the DataProvider annotation with <b>parallel=true</b> in CucumberRunnerTest that extends AbstractTestNGCucumberTests class. <br /><div style="background-color: white; padding: 0px 0px 0px 2px;"><div style="font-family: Consolas; font-size: 10pt; white-space: pre;"><p style="margin: 0px;"><span style="color: #7f0055; font-weight: bold;">public</span> <span style="color: #7f0055; font-weight: bold;">class</span> CucumberRunnerTest <span style="color: #7f0055; font-weight: bold;">extends</span> AbstractTestNGCucumberTests {</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;"> <span style="color: #646464;">@Override</span></p><p style="margin: 0px;"> <span style="color: #646464;">@DataProvider</span>(parallel = <span style="color: #7f0055; font-weight: bold;">true</span>)</p><p style="margin: 0px;"> <span style="color: #7f0055; font-weight: bold;">public</span> Object[][] scenarios() {</p><p style="margin: 0px;"> <span style="color: #7f0055; font-weight: bold;">return</span> <span style="color: #7f0055; font-weight: bold;">super</span>.scenarios();</p><p style="margin: 0px;"> }</p><p style="margin: 0px;">}</p></div></div></li><li>Create a <b>testng.xml</b> file and give <b>parallel=true</b> and <b>data-provider-thread-count=1 </b>and the runner class as shown below.<br /><div style="background-color: white; padding: 0px 0px 0px 2px;"><div style="font-family: Consolas; font-size: 10pt; white-space: pre;"><p style="margin: 15 0 0 0;"><span style="color: #b58900;"><?</span><span style="color: #268bd2;">xml</span><span style="color: #93a1a1;"> version</span><span style="color: #b58900;">=</span><span style="color: #93a1a1;">"</span><span style="color: #b58900;">1.0</span><span style="color: #93a1a1;">" encoding</span><span style="color: #b58900;">=</span><span style="color: #93a1a1;">"</span><span style="color: #b58900;">UTF-8</span><span style="color: #93a1a1;">"</span><span style="color: #b58900;">?></span></p><p style="margin: 0px;"><!<span style="color: #859900;">DOCTYPE</span> <span style="color: #268bd2;">suite</span> SYSTEM "<span style="text-decoration-line: underline; text-decoration-style: solid;">https://testng.org/testng-1.0.dtd</span>"></p><p style="margin: 0px;"><<span style="color: #268bd2;">suite</span> <span style="color: #93a1a1;">name</span>=<span style="color: #93a1a1;">"</span><span style="color: #2aa198;">Suite</span><span style="color: #93a1a1;">"</span> <span style="color: #93a1a1;">parallel</span>=<span style="color: #93a1a1;">"</span><span style="color: #2aa198;">true</span><span style="color: #93a1a1;">"</span> <span style="color: #93a1a1;">data-provider-thread-count</span>=<span style="color: #93a1a1;">"</span><span style="color: #2aa198;">1</span><span style="color: #93a1a1;">"</span> <span style="color: #93a1a1;">verbose</span>=<span style="color: #93a1a1;">"</span><span style="color: #2aa198;">2</span><span style="color: #93a1a1;">"</span>></p><p style="margin: 0px;"> <<span style="color: #268bd2;">test</span> <span style="color: #93a1a1;">name</span>=<span style="color: #93a1a1;">"</span><span style="color: #2aa198;">Test</span><span style="color: #93a1a1;">"</span>></p><p style="margin: 0px;"> <<span style="color: #268bd2;">classes</span>></p><p style="margin: 0px;"> <<span style="color: #268bd2;">class</span> <span style="color: #93a1a1;">name</span>=<span style="color: #93a1a1;">"</span><span style="color: #2aa198;">runners.CucumberRunnerTest</span><span style="color: #93a1a1;">"</span> /></p><p style="margin: 0px;"> </<span style="color: #268bd2;">classes</span>></p><p style="margin: 0px;"> </<span style="color: #268bd2;">test</span>> <span style="color: #93a1a1;"><!--</span></p><p style="margin: 0px;"><span style="color: #93a1a1;"> Test --></span></p><p style="margin: 0px;"></<span style="color: #268bd2;">suite</span>> <span style="color: #93a1a1;"><!--</span></p><p style="margin: 0px;"><span style="color: #93a1a1;">Suite --></span></p></div></div></li><li>In pom.xml add the <b>testng.xml</b> as suiteXml file in <b>maven-surefire-plugin.<br /><div style="background-color: white; padding: 0px 0px 0px 2px;"><div style="font-family: Consolas; font-size: 10pt; white-space: pre;"><p style="margin: 0px;"><<span style="color: #268bd2;">plugin</span>></p><p style="margin: 0px;"> <<span style="color: #268bd2;">groupId</span>>org.apache.maven.plugins</<span style="color: #268bd2;">groupId</span>></p><p style="margin: 0px;"> <<span style="color: #268bd2;">artifactId</span>>maven-surefire-plugin</<span style="color: #268bd2;">artifactId</span>></p><p style="margin: 0px;"> <<span style="color: #268bd2;">version</span>>3.1.2</<span style="color: #268bd2;">version</span>></p><p style="margin: 0px;"> <<span style="color: #268bd2;">configuration</span>></p><p style="margin: 0px;"> <<span style="color: #268bd2;">suiteXmlFiles</span>></p><p style="margin: 0px;"> <<span style="color: #268bd2;">suiteXmlFile</span>>testng.xml</<span style="color: #268bd2;">suiteXmlFile</span>></p><p style="margin: 0px;"> </<span style="color: #268bd2;">suiteXmlFiles</span>></p><p style="margin: 0px;"> </<span style="color: #268bd2;">configuration</span>></p><p style="margin: 0px;"></<span style="color: #268bd2;">plugin</span>></p></div></div></b></li></ul><div>That's all we need to make cucumber scenarios to run parallel with TestNG as testing framework. <br />So, after configurations - <b>How to run the code to see parallel execution ? </b><br /><br /><b>On the command prompt - maven execution</b><br /><ul style="text-align: left;"><li>Navigate to the the project folder location - you should have the pom.xml in it. </li><li>Run below command in Command prompt. <br /><br /><b style="background-color: #fcff01;">mvn -Dbrowser=chrome -Ddataproviderthreadcount=2 test<br /><br /></b></li><li>This command opens two chrome browser parallelly as passing dataproviderthreadcount =2 </li><li>If passed 1 then sequential execution takes place. </li></ul></div><div><b>On the command prompt - jar execution </b><ul style="text-align: left;"><li>Use the <b>maven-assembly-plugin</b> and <b>Main.run</b> method creation technique to create a jar file <br />(scroll down to the complete code section below and see how assembly plugin is configured in <b>pom.xml</b> and how Main.main takes arguments in <b>CucumberRunnerCLI.java</b> class )<br /><br /></li><li>Now to create executable/runnable jar file give below goal in eclipse <br />(Runs As -> Maven build -> Goals) (Note: Make sure to clean the project prior assembling)<br /> <br /><span style="background-color: #fcff01;"><b>clean package assembly:single -Dmaven.test.skip=true</b><br /><br /></span></li><li>Running above command downloads required jar files in .m2 repository and<b> creates and copy the jar file in target folder</b>. <br /><div style="background-color: white; padding: 0px 0px 0px 2px;"><div style="font-family: Consolas; font-size: 10pt; white-space: pre;"><p style="margin: 0px;">[<span style="color: #0037da; font-weight: bold;"> [1;34m</span><span style="color: #0037da; font-weight: bold;">INFO</span> [m] Building jar: E:\Automation\CucumberParallelExecutionTestNG\
<b>target\CucumberParallelExecutionTestNG-0.0.1-SNAPSHOT-jar-with-dependencies.jar</b></p><p style="margin: 0px;">[<span style="color: #0037da; font-weight: bold;"> [1;34m</span><span style="color: #0037da; font-weight: bold;">INFO</span> [m] <span style="font-weight: bold;"> [1m</span><span style="font-weight: bold;">------------------------------------------------------------------------</span> [m</p><p style="margin: 0px;">[<span style="color: #0037da; font-weight: bold;"> [1;34m</span><span style="color: #0037da; font-weight: bold;">INFO</span> [m] <span style="color: #13a10e; font-weight: bold;"> [1;32m</span><span style="color: #13a10e; font-weight: bold;">BUILD SUCCESS
</span></p></div></div></li><li>Use below command to run the scenarios from jar generated in target folder. <br /><br /><b style="background-color: #fcff01;">java -Ddataproviderthreadcount=1 -Dbrowser=chrome -jar CucumberParallelExecutionTestNG-0.0.1-SNAPSHOT-jar-with-dependencies.jar</b></li></ul></div><div><b><br />In the Eclipse Run As TestNG with Run Configurations</b><br /><ul style="text-align: left;"><li><span style="background-color: #fcff01;"><b>Run As -> TestNG -> Run Configurations -> VM Arguments <br /> --> -Dbrowser=chrome -Ddataproviderthreadcount=2</b></span></li></ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiZj2Eh-NwKNXzQdkEFbxiIIO39m0ooC7K9SOoGpR9JZd24DI2Y1OghFaV-jXZy6VcXAN9aN8B38ZCOQwI4jGTvOkHGOjCz-ua-P1yx5X558NSkyUx1YVryxEO7EYthS1v3oquWcxLdeJjWN_veKvVbzzGxiK8kkv0MJ8PJ6FaTTGje563JGQXuyfHndtA3" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="475" data-original-width="616" src="https://blogger.googleusercontent.com/img/a/AVvXsEiZj2Eh-NwKNXzQdkEFbxiIIO39m0ooC7K9SOoGpR9JZd24DI2Y1OghFaV-jXZy6VcXAN9aN8B38ZCOQwI4jGTvOkHGOjCz-ua-P1yx5X558NSkyUx1YVryxEO7EYthS1v3oquWcxLdeJjWN_veKvVbzzGxiK8kkv0MJ8PJ6FaTTGje563JGQXuyfHndtA3=s16000" /></a></div><br /><br />This is how one could able to run the scenarios in parallel with TestNG as the testing framework. <br /><br /><br /><b>Interesting Research Observations: </b></div></div></div><div>Over the internet there are bunch of suggestions with maven sure fire plugin to play with parallel=method, threadCount=3 and incase of maven fail safe plugin to play with dataproviderthreadcount and value in the properties those didn't work for me at least. <br /><br />i.e., <b>None </b>of the below configurations worked to run scenarios parallel. <br /><div style="padding: 0px 0px 0px 2px;"><div style="font-family: Consolas; font-size: 10pt; white-space: pre;"><p style="margin: 15px 0px 0px;"><b><span style="background-color: #fcff01;">maven-surefire-plugin with parallel=true and threadCount=3 DID NOT work</span><span style="background-color: white;">
</span></b><span style="background-color: white; font-size: 10pt;"><</span><span style="background-color: white; color: #268bd2; font-size: 10pt; text-decoration-color: rgb(130, 160, 190); text-decoration-line: underline; text-decoration-style: wavy;">plugin</span><span style="background-color: white; font-size: 10pt;">></span></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">groupId</span>>org.apache.maven.plugins</<span style="color: #268bd2;">groupId</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">artifactId</span>>maven-surefire-plugin</<span style="color: #268bd2;">artifactId</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">version</span>>3.1.2</<span style="color: #268bd2;">version</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">configuration</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">parallel</span>>methods</<span style="color: #268bd2;">parallel</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">threadCount</span>>3</<span style="color: #268bd2;">threadCount</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">perCoreThreadCount</span>>false</<span style="color: #268bd2;">perCoreThreadCount</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">useUnlimitedThreads</span>>false</<span style="color: #268bd2;">useUnlimitedThreads</span>></p><p style="background-color: white; margin: 0px;"> </<span style="color: #268bd2;">configuration</span>></p><p style="background-color: white; margin: 0px;"></<span style="color: #268bd2;">plugin</span>></p><p style="margin: 0px;"><span style="background-color: white;">
</span><b style="background-color: #fcff01; font-size: 13.3333px;">maven-failsafe-plugin with dataproviderthreadcount property with value DID NOT work. </b></p><p style="background-color: white; margin: 0px;"><<span style="color: #268bd2; text-decoration-color: rgb(255, 0, 128); text-decoration-line: underline; text-decoration-style: wavy;">p</span><span style="color: #268bd2;">lugin</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">groupId</span>>org.apache.maven.plugins</<span style="color: #268bd2;">groupId</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">artifactId</span>>maven-failsafe-plugin</<span style="color: #268bd2;">artifactId</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">version</span>>2.22.0</<span style="color: #268bd2;">version</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">executions</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">execution</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">goals</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">goal</span>>integration-test</<span style="color: #268bd2;">goal</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">goal</span>>verify</<span style="color: #268bd2;">goal</span>></p><p style="background-color: white; margin: 0px;"> </<span style="color: #268bd2;">goals</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">configuration</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">properties</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">property</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">name</span>>dataproviderthreadcount</<span style="color: #268bd2;">name</span>></p><p style="background-color: white; margin: 0px;"> <<span style="color: #268bd2;">value</span>>2</<span style="color: #268bd2;">value</span>></p><p style="background-color: white; margin: 0px;"> </<span style="color: #268bd2;">property</span>></p><p style="background-color: white; margin: 0px;"> </<span style="color: #268bd2;">properties</span>></p><p style="background-color: white; margin: 0px;"> </<span style="color: #268bd2;">configuration</span>></p><p style="background-color: white; margin: 0px;"> </<span style="color: #268bd2;">execution</span>></p><p style="background-color: white; margin: 0px;"> </<span style="color: #268bd2;">executions</span>></p><p style="background-color: white; margin: 0px;"></<span style="color: #268bd2;">plugin</span>></p><p style="background-color: white; margin: 0px;">----------------------------------------------------------------------------------------------------------</p><p style="background-color: white; margin: 0px;"><br /></p><p style="background-color: white; margin: 0px;"><b style="font-family: "Times New Roman"; font-size: medium; white-space: normal;">Code base: <br /><br /></b></p></div></div></div><b>
Login.feature
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #888888;">#Author: Sadakar Pochampalli</span><span style="color: #0066bb; font-weight: bold;"></span>
<span style="color: #007700;">@LoginFeature</span><span style="color: #0066bb; font-weight: bold;"></span>
<span style="color: #008800; font-weight: bold;">Feature:</span><span style="color: #0066bb; font-weight: bold;"> Login page validations</span>
<span style="color: #0066bb; font-weight: bold;"> </span><span style="color: #008800; font-weight: bold;">Background:</span><span style="color: #0066bb; font-weight: bold;"> </span>
<span style="color: #008800; font-weight: bold;"> Given </span><span style="color: #0066bb; font-weight: bold;">User is on login page</span>
<span style="color: #0066bb; font-weight: bold;"> </span><span style="color: #007700;">@Login</span><span style="color: #0066bb; font-weight: bold;"></span>
<span style="color: #0066bb; font-weight: bold;"> </span><span style="color: #008800; font-weight: bold;">Scenario:</span><span style="color: #0066bb; font-weight: bold;"> Login to Orange HRM</span>
<span style="color: #008800; font-weight: bold;"> When </span><span style="color: #0066bb; font-weight: bold;">User enters username "</span><span style="background-color: #fff0f0;">Admin</span><span style="color: #0066bb; font-weight: bold;">"</span>
<span style="color: #0066bb; font-weight: bold;"> </span><span style="color: #008800; font-weight: bold;">And </span><span style="color: #0066bb; font-weight: bold;">User enters password "</span><span style="background-color: #fff0f0;">admin123</span><span style="color: #0066bb; font-weight: bold;">"</span>
<span style="color: #0066bb; font-weight: bold;"> </span><span style="color: #008800; font-weight: bold;">And </span><span style="color: #0066bb; font-weight: bold;">User clicks on Login button</span>
<span style="color: #0066bb; font-weight: bold;"> </span><span style="color: #008800; font-weight: bold;">Then </span><span style="color: #0066bb; font-weight: bold;">User should navigate to Orange HRM home page</span>
<span style="color: #0066bb; font-weight: bold;"> </span><span style="color: #007700;">@ForgotPassword</span><span style="color: #0066bb; font-weight: bold;"></span>
<span style="color: #0066bb; font-weight: bold;"> </span><span style="color: #008800; font-weight: bold;">Scenario:</span><span style="color: #0066bb; font-weight: bold;"> Forgot password link verification</span>
<span style="color: #008800; font-weight: bold;"> Then </span><span style="color: #0066bb; font-weight: bold;">User verifies Forgot password link display</span>
</pre></div><br /> pom.xml
</b><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #007700;"><project</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://maven.apache.org/POM/4.0.0"</span>
<span style="color: #0000cc;">xmlns:xsi=</span><span style="background-color: #fff0f0;">"http://www.w3.org/2001/XMLSchema-instance"</span>
<span style="color: #0000cc;">xsi:schemaLocation=</span><span style="background-color: #fff0f0;">"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><modelVersion></span>4.0.0<span style="color: #007700;"></modelVersion></span>
<span style="color: #007700;"><groupId></span>CucumberParallelExecutionTestNG<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>CucumberParallelExecutionTestNG<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>0.0.1-SNAPSHOT<span style="color: #007700;"></version></span>
<span style="color: #007700;"><name></span>CucumberParallelExecutionTestNG<span style="color: #007700;"></name></span>
<span style="color: #007700;"><description></span>CucumberParallelExecutionTestNG<span style="color: #007700;"></description></span>
<span style="color: #007700;"><dependencies></span>
<span style="color: #007700;"><dependency></span>
<span style="color: #007700;"><groupId></span>io.cucumber<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>cucumber-java<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>7.12.0<span style="color: #007700;"></version></span>
<span style="color: #007700;"></dependency></span>
<span style="color: #888888;"><!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java --></span>
<span style="color: #007700;"><dependency></span>
<span style="color: #007700;"><groupId></span>io.cucumber<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>cucumber-testng<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>7.12.0<span style="color: #007700;"></version></span>
<span style="color: #007700;"></dependency></span>
<span style="color: #007700;"><dependency></span>
<span style="color: #007700;"><groupId></span>org.seleniumhq.selenium<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>selenium-java<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>4.10.0<span style="color: #007700;"></version></span>
<span style="color: #007700;"></dependency></span>
<span style="color: #888888;"><!-- https://mvnrepository.com/artifact/org.testng/testng --></span>
<span style="color: #888888;"><!-- <dependency></span>
<span style="color: #888888;"> <groupId>org.testng</groupId></span>
<span style="color: #888888;"> <artifactId>testng</artifactId></span>
<span style="color: #888888;"> <version>7.8.0</version></span>
<span style="color: #888888;"> </dependency></span>
<span style="color: #888888;">--></span>
<span style="color: #007700;"><dependency></span>
<span style="color: #007700;"><groupId></span>tech.grasshopper<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>extentreports-cucumber7-adapter<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>1.2.0<span style="color: #007700;"></version></span>
<span style="color: #007700;"></dependency></span>
<span style="color: #007700;"><dependency></span>
<span style="color: #007700;"><groupId></span>org.projectlombok<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>lombok<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>1.18.24<span style="color: #007700;"></version></span>
<span style="color: #007700;"><scope></span>provided<span style="color: #007700;"></scope></span>
<span style="color: #007700;"></dependency></span>
<span style="color: #888888;"><!-- https://mvnrepository.com/artifact/javax.mail/mail --></span>
<span style="color: #007700;"><dependency></span>
<span style="color: #007700;"><groupId></span>javax.mail<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>mail<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>1.4.7<span style="color: #007700;"></version></span>
<span style="color: #007700;"></dependency></span>
<span style="color: #007700;"></dependencies></span>
<span style="color: #007700;"><build></span>
<span style="color: #007700;"><pluginManagement></span>
<span style="color: #007700;"><plugins></span>
<span style="color: #007700;"><plugin></span>
<span style="color: #007700;"><groupId></span>org.apache.maven.plugins<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>maven-surefire-plugin<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>3.1.2<span style="color: #007700;"></version></span>
<span style="color: #007700;"><configuration></span>
<span style="color: #007700;"><suiteXmlFiles></span>
<span style="color: #007700;"><suiteXmlFile></span>testng.xml<span style="color: #007700;"></suiteXmlFile></span>
<span style="color: #007700;"></suiteXmlFiles></span>
<span style="color: #007700;"></configuration></span>
<span style="color: #007700;"></plugin></span>
<span style="color: #007700;"><plugin></span>
<span style="color: #007700;"><groupId></span>org.apache.maven.plugins<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>maven-compiler-plugin<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>3.11.0<span style="color: #007700;"></version></span>
<span style="color: #007700;"><configuration></span>
<span style="color: #007700;"><source></span>17<span style="color: #007700;"></source></span>
<span style="color: #007700;"><target></span>17<span style="color: #007700;"></target></span>
<span style="color: #007700;"></configuration></span>
<span style="color: #007700;"></plugin></span>
<span style="color: #007700;"><plugin></span>
<span style="color: #007700;"><groupId></span>org.apache.maven.plugins<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>maven-assembly-plugin<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>3.1.1<span style="color: #007700;"></version></span>
<span style="color: #007700;"><configuration></span>
<span style="color: #007700;"><archive></span>
<span style="color: #007700;"><manifest></span>
<span style="color: #007700;"><addClasspath></span>true<span style="color: #007700;"></addClasspath></span>
<span style="color: #007700;"><mainClass></span>runners.CucumberRunnerCLI<span style="color: #007700;"></mainClass></span>
<span style="color: #007700;"></manifest></span>
<span style="color: #007700;"><manifestEntries></span>
<span style="color: #007700;"><Class-Path></span>.<span style="color: #007700;"></Class-Path></span>
<span style="color: #007700;"></manifestEntries></span>
<span style="color: #007700;"></archive></span>
<span style="color: #007700;"><descriptorRefs></span>
<span style="color: #007700;"><descriptorRef></span>jar-with-dependencies<span style="color: #007700;"></descriptorRef></span>
<span style="color: #007700;"></descriptorRefs></span>
<span style="color: #007700;"></configuration></span>
<span style="color: #007700;"><executions></span>
<span style="color: #007700;"><execution></span>
<span style="color: #007700;"><id></span>make-assembly<span style="color: #007700;"></id></span>
<span style="color: #007700;"><phase></span>package<span style="color: #007700;"></phase></span>
<span style="color: #007700;"><goals></span>
<span style="color: #007700;"><goal></span>single<span style="color: #007700;"></goal></span>
<span style="color: #007700;"></goals></span>
<span style="color: #007700;"></execution></span>
<span style="color: #007700;"></executions></span>
<span style="color: #007700;"></plugin></span>
<span style="color: #007700;"></plugins></span>
<span style="color: #007700;"></pluginManagement></span>
<span style="color: #007700;"></build></span>
<span style="color: #007700;"></project></span>
</pre></div><br /><b>testng.xml
</b><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #557799;"><?xml version="1.0" encoding="UTF-8"?></span>
<span style="color: #557799;"><!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"></span>
<span style="color: #007700;"><suite</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Suite"</span> <span style="color: #0000cc;">parallel=</span><span style="background-color: #fff0f0;">"true"</span> <span style="color: #0000cc;">data-provider-thread-count=</span><span style="background-color: #fff0f0;">"1"</span> <span style="color: #0000cc;">verbose=</span><span style="background-color: #fff0f0;">"2"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><test</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Test"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><classes></span>
<span style="color: #007700;"><class</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"runners.CucumberRunnerTest"</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"></classes></span>
<span style="color: #007700;"></test></span> <span style="color: #888888;"><!--</span>
<span style="color: #888888;"> Test --></span>
<span style="color: #007700;"></suite></span> <span style="color: #888888;"><!--</span>
<span style="color: #888888;">Suite --></span>
</pre></div><br /><b>WebDriverFactory.java
</b><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">package</span> driverfactory<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.openqa.selenium.WebDriver</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.openqa.selenium.chrome.ChromeDriver</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.openqa.selenium.chrome.ChromeOptions</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.openqa.selenium.edge.EdgeDriver</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">final</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">WebDriverFactory</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #008800; font-weight: bold;">static</span> ThreadLocal<span style="color: #333333;"><</span>WebDriver<span style="color: #333333;">></span> driver <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ThreadLocal<span style="color: #333333;"><>();</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setDriver</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
String browser <span style="color: #333333;">=</span> System<span style="color: #333333;">.</span><span style="color: #0000cc;">getProperty</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"browser"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"chrome"</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>browser<span style="color: #333333;">.</span><span style="color: #0000cc;">equalsIgnoreCase</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"chrome"</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">setProperty</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"webdriver.chrome.driver"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"E:\\Drivers\\chromedriver.exe"</span><span style="color: #333333;">);</span>
ChromeOptions options <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ChromeOptions<span style="color: #333333;">();</span>
options<span style="color: #333333;">.</span><span style="color: #0000cc;">addArguments</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"--remote-allow-origins=*"</span><span style="color: #333333;">);</span>
driver<span style="color: #333333;">.</span><span style="color: #0000cc;">set</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> ChromeDriver<span style="color: #333333;">(</span>options<span style="color: #333333;">));</span>
getDriver<span style="color: #333333;">().</span><span style="color: #0000cc;">manage</span><span style="color: #333333;">().</span><span style="color: #0000cc;">window</span><span style="color: #333333;">().</span><span style="color: #0000cc;">maximize</span><span style="color: #333333;">();</span>
getDriver<span style="color: #333333;">().</span><span style="color: #0000cc;">manage</span><span style="color: #333333;">().</span><span style="color: #0000cc;">deleteAllCookies</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>browser<span style="color: #333333;">.</span><span style="color: #0000cc;">equalsIgnoreCase</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"edge"</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">setProperty</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"webdriver.edge.driver"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"E:\\Drivers\\msedgedriver.exe"</span><span style="color: #333333;">);</span>
driver<span style="color: #333333;">.</span><span style="color: #0000cc;">set</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> EdgeDriver<span style="color: #333333;">());</span>
getDriver<span style="color: #333333;">().</span><span style="color: #0000cc;">manage</span><span style="color: #333333;">().</span><span style="color: #0000cc;">window</span><span style="color: #333333;">().</span><span style="color: #0000cc;">maximize</span><span style="color: #333333;">();</span>
getDriver<span style="color: #333333;">().</span><span style="color: #0000cc;">manage</span><span style="color: #333333;">().</span><span style="color: #0000cc;">deleteAllCookies</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> WebDriver <span style="color: #0066bb; font-weight: bold;">getDriver</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> driver<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">closeDriver</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
driver<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">().</span><span style="color: #0000cc;">quit</span><span style="color: #333333;">();</span>
driver<span style="color: #333333;">.</span><span style="color: #0000cc;">remove</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><br /><b>Hooks.java
</b><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">package</span> hooks<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.net.InetAddress</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.net.UnknownHostException</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">driverfactory.WebDriverFactory</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.java.After</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.java.AfterAll</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.java.Before</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.java.Scenario</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Hooks</span> <span style="color: #333333;">{</span>
<span style="color: #555555; font-weight: bold;">@Before</span><span style="color: #333333;">(</span>order <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">before</span><span style="color: #333333;">(</span>Scenario scenaio<span style="color: #333333;">)</span> <span style="color: #008800; font-weight: bold;">throws</span> Exception <span style="color: #333333;">{</span>
WebDriverFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">setDriver</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Current Thread Name:"</span> <span style="color: #333333;">+</span> Thread<span style="color: #333333;">.</span><span style="color: #0000cc;">currentThread</span><span style="color: #333333;">().</span><span style="color: #0000cc;">getName</span><span style="color: #333333;">());</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Current Thread ID:"</span> <span style="color: #333333;">+</span> Thread<span style="color: #333333;">.</span><span style="color: #0000cc;">currentThread</span><span style="color: #333333;">().</span><span style="color: #0000cc;">getId</span><span style="color: #333333;">());</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@After</span><span style="color: #333333;">(</span>order <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">after</span><span style="color: #333333;">()</span> <span style="color: #008800; font-weight: bold;">throws</span> Exception <span style="color: #333333;">{</span>
WebDriverFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">closeDriver</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@AfterAll</span><span style="color: #333333;">(</span>order <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">afterAll</span><span style="color: #333333;">()</span> <span style="color: #008800; font-weight: bold;">throws</span> UnknownHostException <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"AfterAll - with order=0"</span><span style="color: #333333;">);</span>
InetAddress localhost <span style="color: #333333;">=</span> InetAddress<span style="color: #333333;">.</span><span style="color: #0000cc;">getLocalHost</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"System IP Address : "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>localhost<span style="color: #333333;">.</span><span style="color: #0000cc;">getHostAddress</span><span style="color: #333333;">()).</span><span style="color: #0000cc;">trim</span><span style="color: #333333;">());</span>
Runtime<span style="color: #333333;">.</span><span style="color: #0000cc;">getRuntime</span><span style="color: #333333;">().</span><span style="color: #0000cc;">addShutdownHook</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Thread<span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Runnable<span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">run</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Write email code in this method - Shutdown Hook is running and this text prints before JVM shut downs!"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}));</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"This text prints before Shutdown hook"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><br /><b>LoginPageFactory.java
</b><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">package</span> pagefactory<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.openqa.selenium.WebDriver</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.openqa.selenium.WebElement</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.openqa.selenium.support.FindBy</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">LoginPageFactory</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> WebDriver driver<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">LoginPageFactory</span><span style="color: #333333;">(</span>WebDriver driver<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">driver</span> <span style="color: #333333;">=</span> driver<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Username locator</span>
<span style="color: #555555; font-weight: bold;">@FindBy</span><span style="color: #333333;">(</span>xpath <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"//input[@name='username']"</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> WebElement userName<span style="color: #333333;">;</span>
<span style="color: #888888;">// Password locator</span>
<span style="color: #555555; font-weight: bold;">@FindBy</span><span style="color: #333333;">(</span>xpath <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"//input[@name='password']"</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> WebElement passWord<span style="color: #333333;">;</span>
<span style="color: #888888;">// Login button locator</span>
<span style="color: #555555; font-weight: bold;">@FindBy</span><span style="color: #333333;">(</span>xpath <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"//button[@type='submit']"</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> WebElement loginButton<span style="color: #333333;">;</span>
<span style="color: #888888;">// Forgot password locator</span>
<span style="color: #555555; font-weight: bold;">@FindBy</span><span style="color: #333333;">(</span>xpath <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"//p[@class='oxd-text oxd-text--p orangehrm-login-forgot-header']"</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> WebElement forgotPassword<span style="color: #333333;">;</span>
<span style="color: #888888;">// Method that performs Username action</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">enterUsername</span><span style="color: #333333;">(</span>String uname<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
userName<span style="color: #333333;">.</span><span style="color: #0000cc;">sendKeys</span><span style="color: #333333;">(</span>uname<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Method that performs Password action</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">enterPassword</span><span style="color: #333333;">(</span>String pwd<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
passWord<span style="color: #333333;">.</span><span style="color: #0000cc;">sendKeys</span><span style="color: #333333;">(</span>pwd<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Method that performs Login action</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">clickLogin</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
loginButton<span style="color: #333333;">.</span><span style="color: #0000cc;">click</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Method that performs Forgot Password link verification</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">boolean</span> <span style="color: #0066bb; font-weight: bold;">isForgotPasswordLinkPresent</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> forgotPassword<span style="color: #333333;">.</span><span style="color: #0000cc;">isDisplayed</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><br /><b>CucumberRunnerCLI.java
</b><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">package</span> runners<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.core.cli.*</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">CucumberRunnerCLI</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">main</span><span style="color: #333333;">(</span>String<span style="color: #333333;">[]</span> args<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
String threadCount <span style="color: #333333;">=</span> System<span style="color: #333333;">.</span><span style="color: #0000cc;">getProperty</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"dataproviderthreadcount"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"1"</span><span style="color: #333333;">);</span>
Main<span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span>
<span style="background-color: #fff0f0;">"classpath:scenarios"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-g"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"driverfactory"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-g"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"hooks"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-g"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"pagefactory"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-g"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"runners"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-g"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"stepdef"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-p"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"pretty"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-p"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"json:target/cucumber-reports/cucumber.json"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-p"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"html:target/cucumber-reports/cucumber-report.html"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-m"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"--threads"</span><span style="color: #333333;">,</span>threadCount
<span style="color: #333333;">},</span> Thread<span style="color: #333333;">.</span><span style="color: #0000cc;">currentThread</span><span style="color: #333333;">().</span><span style="color: #0000cc;">getContextClassLoader</span><span style="color: #333333;">());</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><br /><b>CucumberRunnerTest.java
</b><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">package</span> runners<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.testng.annotations.DataProvider</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.testng.AbstractTestNGCucumberTests</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.testng.CucumberOptions</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@CucumberOptions</span><span style="color: #333333;">(</span>
features <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"classpath:scenarios"</span><span style="color: #333333;">,</span>
tags <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"@Login or @ForgotPassword"</span><span style="color: #333333;">,</span>
glue <span style="color: #333333;">=</span> <span style="color: #333333;">{</span> <span style="background-color: #fff0f0;">"driverfactory"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"hooks"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"pagefactory"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"runners"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"stepdef"</span> <span style="color: #333333;">},</span>
plugin <span style="color: #333333;">=</span> <span style="color: #333333;">{</span> <span style="background-color: #fff0f0;">"pretty"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"json:target/cucumber-reports/cucumber.json"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"html:target/cucumber-reports/cucucmber-report.html"</span> <span style="color: #333333;">},</span>
monochrome <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">true</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">CucumberRunnerTest</span> <span style="color: #008800; font-weight: bold;">extends</span> AbstractTestNGCucumberTests <span style="color: #333333;">{</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #555555; font-weight: bold;">@DataProvider</span><span style="color: #333333;">(</span>parallel <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">true</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> Object<span style="color: #333333;">[][]</span> <span style="color: #0066bb; font-weight: bold;">scenarios</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">super</span><span style="color: #333333;">.</span><span style="color: #0000cc;">scenarios</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><br /><b>LoginStepDef.java
</b><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">package</span> stepdef<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.openqa.selenium.support.PageFactory</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.testng.Assert</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">driverfactory.WebDriverFactory</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.java.en.Given</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.java.en.Then</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.java.en.When</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">pagefactory.LoginPageFactory</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">LoginStepDef</span> <span style="color: #333333;">{</span>
LoginPageFactory login <span style="color: #333333;">=</span> PageFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">initElements</span><span style="color: #333333;">(</span>WebDriverFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">getDriver</span><span style="color: #333333;">(),</span> LoginPageFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">class</span><span style="color: #333333;">);</span>
<span style="color: #555555; font-weight: bold;">@Given</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"User is on login page"</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">user_is_on_login_page</span><span style="color: #333333;">()</span> <span style="color: #008800; font-weight: bold;">throws</span> InterruptedException <span style="color: #333333;">{</span>
WebDriverFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">getDriver</span><span style="color: #333333;">().</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"https://opensource-demo.orangehrmlive.com/web/index.php/auth/login"</span><span style="color: #333333;">);</span>
Thread<span style="color: #333333;">.</span><span style="color: #0000cc;">sleep</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3000</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@When</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"User enters username {string}"</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">user_enters_username</span><span style="color: #333333;">(</span>String username<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
login<span style="color: #333333;">.</span><span style="color: #0000cc;">enterUsername</span><span style="color: #333333;">(</span>username<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@When</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"User enters password {string}"</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">user_enters_password</span><span style="color: #333333;">(</span>String password<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
login<span style="color: #333333;">.</span><span style="color: #0000cc;">enterPassword</span><span style="color: #333333;">(</span>password<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@When</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"User clicks on Login button"</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">user_clicks_on_login_button</span><span style="color: #333333;">()</span> <span style="color: #008800; font-weight: bold;">throws</span> InterruptedException <span style="color: #333333;">{</span>
login<span style="color: #333333;">.</span><span style="color: #0000cc;">clickLogin</span><span style="color: #333333;">();</span>
Thread<span style="color: #333333;">.</span><span style="color: #0000cc;">sleep</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3000</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@Then</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"User should navigate to Orange HRM home page"</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">user_should_navigate_to_orange_hrm_home_page</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
String expectedURLToNavigate <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"https://opensource-demo.orangehrmlive.com/web/index.php/dashboard/index"</span><span style="color: #333333;">;</span>
String actualURLNavigated <span style="color: #333333;">=</span> WebDriverFactory<span style="color: #333333;">.</span><span style="color: #0000cc;">getDriver</span><span style="color: #333333;">().</span><span style="color: #0000cc;">getCurrentUrl</span><span style="color: #333333;">();</span>
Assert<span style="color: #333333;">.</span><span style="color: #0000cc;">assertEquals</span><span style="color: #333333;">(</span>actualURLNavigated<span style="color: #333333;">,</span> expectedURLToNavigate<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@Then</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"User verifies Forgot password link display"</span><span style="color: #333333;">)</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">user_verifies_forgot_password_link_display</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
Assert<span style="color: #333333;">.</span><span style="color: #0000cc;">assertTrue</span><span style="color: #333333;">(</span>login<span style="color: #333333;">.</span><span style="color: #0000cc;">isForgotPasswordLinkPresent</span><span style="color: #333333;">());</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><div><br /></div><b>
cucumber.properties
</b><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #0000cc;">cucumber.publish.enabled</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">true</span>
</pre></div><div><br /></div><b>
Take another look at the folder structure:</b><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEht_t2mirmITcmB1Y5uHtTrsm6uQWqgy3EJcF0r0fDfmcGqWTJ5-mlRtxp5G4cQbI8b1xMNIGJP03AXd6O_1cIK37WMFEFdlwMyumPAkVydzI5dVLKnWrRm7xnkMdEZXfBlsCunv2Gmgx8gU36QDXhwBK8tntxYeApM2J9vY9ejLBz8zWKP7voSSN_h9LW1" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="548" data-original-width="492" src="https://blogger.googleusercontent.com/img/a/AVvXsEht_t2mirmITcmB1Y5uHtTrsm6uQWqgy3EJcF0r0fDfmcGqWTJ5-mlRtxp5G4cQbI8b1xMNIGJP03AXd6O_1cIK37WMFEFdlwMyumPAkVydzI5dVLKnWrRm7xnkMdEZXfBlsCunv2Gmgx8gU36QDXhwBK8tntxYeApM2J9vY9ejLBz8zWKP7voSSN_h9LW1=s16000" /></a></div><br />I hope this helped you a bit ! If you liked it do subscribe my <b><a href="https://www.youtube.com/channel/UCNI54-ZwNAjSMknRCfdyRCQ" rel="nofollow" target="_blank">YouTube</a></b> channel for interesting tech updates. </div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-6954366144298047762023-05-12T01:21:00.006+05:302023-06-07T18:50:04.700+05:30Chrome Driver Storage and How to turn off auto updates for Chrome<p><a href="https://chromedriver.storage.googleapis.com/index.html" rel="nofollow" target="_blank"> https://chromedriver.storage.googleapis.com/index.html</a></p><p><br /></p><p><a href="https://www.chromium.org/administrators/turning-off-auto-updates/">https://www.chromium.org/administrators/turning-off-auto-updates/</a></p>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-34902272172986389692023-04-26T13:21:00.004+05:302023-04-26T13:21:44.600+05:30Could not start a new session. Response code 500. Message: unknown error: DevToolsActivePort file doesn't exist | Selenium, TestNG, Cucumber, Chrome browser<p>While we were trying to run the automation code in AWS workspaces, we stuck with the following error message and the temporary solution was to add the following argument to the chrome browser. </p><p><span><b style="background-color: #fcff01;">options.addArguments("--remote-debugging-port=9222"); <br /><br /></b><span style="background-color: white;">The observation is that even after adding this argument, we have to make sure that the browser is NOT opened in the AWS instance. </span></span></p><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #333333;">[</span>RemoteTestNG<span style="color: #333333;">]</span> detected TestNG version <span style="color: #6600ee; font-weight: bold;">7.4</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Failed to load <span style="color: #008800; font-weight: bold;">class</span> <span style="background-color: #ffaaaa; color: red;">"</span><span style="color: #bb0066; font-weight: bold;">org</span><span style="color: #333333;">.</span><span style="color: #0000cc;">slf4j</span><span style="color: #333333;">.</span><span style="color: #0000cc;">impl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">StaticLoggerBinder</span><span style="background-color: #ffaaaa; color: red;">"</span><span style="color: #333333;">.</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Defaulting to no<span style="color: #333333;">-</span>operation <span style="color: #333333;">(</span>NOP<span style="color: #333333;">)</span> logger implementation
<span style="color: #997700; font-weight: bold;">SLF4J:</span> See <span style="color: #997700; font-weight: bold;">http:</span><span style="color: #888888;">//www.slf4j.org/codes.html#StaticLoggerBinder for further details.</span>
Starting ChromeDriver <span style="color: #6600ee; font-weight: bold;">111.0</span><span style="color: #333333;">.6</span><span style="color: #6600ee; font-weight: bold;">615.69</span> <span style="color: #333333;">(</span>bd2a7bcb881c11e8cfe3078709382934e3916914<span style="color: #333333;">-</span>refs<span style="color: #333333;">/</span>branch<span style="color: #333333;">-</span>heads<span style="color: #333333;">/</span><span style="color: #0000dd; font-weight: bold;">5615</span><span style="background-color: #ffaaaa; color: red;">@</span><span style="color: #333333;">{</span><span style="background-color: #ffaaaa; color: red;">#</span><span style="color: #0000dd; font-weight: bold;">936</span><span style="color: #333333;">})</span> on port <span style="color: #0000dd; font-weight: bold;">16598</span>
Only local connections are allowed<span style="color: #333333;">.</span>
Please see <span style="color: #997700; font-weight: bold;">https:</span><span style="color: #888888;">//chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.</span>
ChromeDriver was started successfully<span style="color: #333333;">.</span>
<span style="color: #997700; font-weight: bold;">FAILED:</span> test
org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SessionNotCreatedException</span><span style="color: #333333;">:</span> Could not start a <span style="color: #008800; font-weight: bold;">new</span> session<span style="color: #333333;">.</span> Response code <span style="color: #0000dd; font-weight: bold;">500</span><span style="color: #333333;">.</span> <span style="color: #997700; font-weight: bold;">Message:</span> unknown <span style="color: #997700; font-weight: bold;">error:</span> DevToolsActivePort file doesn<span style="background-color: #ffaaaa; color: red;">'</span>t exist
Host <span style="color: #997700; font-weight: bold;">info:</span> <span style="color: #997700; font-weight: bold;">host:</span> <span style="background-color: #ffaaaa; color: red;">'</span>DESKTOP<span style="color: #333333;">-</span><span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">ip:</span> <span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #6600ee; font-weight: bold;">10.222</span><span style="color: #333333;">.</span><span style="color: #6600ee; font-weight: bold;">112.9</span><span style="background-color: #ffaaaa; color: red;">'</span>
Build <span style="color: #997700; font-weight: bold;">info:</span> <span style="color: #997700; font-weight: bold;">version:</span> <span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #6600ee; font-weight: bold;">4.9</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">revision:</span> <span style="background-color: #ffaaaa; color: red;">'</span>d7057100a6<span style="background-color: #ffaaaa; color: red;">'</span>
System <span style="color: #997700; font-weight: bold;">info:</span> os<span style="color: #333333;">.</span><span style="color: #0000cc;">name</span><span style="color: #333333;">:</span> <span style="background-color: #ffaaaa; color: red;">'</span>Windows <span style="color: #0000dd; font-weight: bold;">10</span><span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> os<span style="color: #333333;">.</span><span style="color: #0000cc;">arch</span><span style="color: #333333;">:</span> <span style="background-color: #ffaaaa; color: red;">'</span>amd64<span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> os<span style="color: #333333;">.</span><span style="color: #0000cc;">version</span><span style="color: #333333;">:</span> <span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #6600ee; font-weight: bold;">10.0</span><span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> java<span style="color: #333333;">.</span><span style="color: #0000cc;">version</span><span style="color: #333333;">:</span> <span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #6600ee; font-weight: bold;">17.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">6</span><span style="background-color: #ffaaaa; color: red;">'</span>
Driver <span style="color: #997700; font-weight: bold;">info:</span> org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">chrome</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ChromeDriver</span>
<span style="color: #997700; font-weight: bold;">Command:</span> <span style="color: #333333;">[</span><span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">,</span> newSession <span style="color: #333333;">{</span>capabilities<span style="color: #333333;">=[</span>Capabilities <span style="color: #333333;">{</span><span style="color: #997700; font-weight: bold;">acceptInsecureCerts:</span> <span style="color: #008800; font-weight: bold;">true</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">browserName:</span> chrome<span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">goog:chromeOptions:</span> <span style="color: #333333;">{</span><span style="color: #997700; font-weight: bold;">args:</span> <span style="color: #333333;">[--</span>remote<span style="color: #333333;">-</span>allow<span style="color: #333333;">-</span>origins<span style="color: #333333;">=*,</span> <span style="color: #333333;">--</span>ignore<span style="color: #333333;">-</span>certificate<span style="color: #333333;">-</span>errors<span style="color: #333333;">,</span> <span style="color: #333333;">--</span>disable<span style="color: #333333;">-</span>dev<span style="color: #333333;">-</span>shm<span style="color: #333333;">-</span>usage<span style="color: #333333;">],</span> <span style="color: #997700; font-weight: bold;">extensions:</span> <span style="color: #333333;">[]}}]}]</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ProtocolHandshake</span><span style="color: #333333;">.</span><span style="color: #0000cc;">createSession</span><span style="color: #333333;">(</span>ProtocolHandshake<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">136</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ProtocolHandshake</span><span style="color: #333333;">.</span><span style="color: #0000cc;">createSession</span><span style="color: #333333;">(</span>ProtocolHandshake<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">94</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ProtocolHandshake</span><span style="color: #333333;">.</span><span style="color: #0000cc;">createSession</span><span style="color: #333333;">(</span>ProtocolHandshake<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">68</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">HttpCommandExecutor</span><span style="color: #333333;">.</span><span style="color: #0000cc;">execute</span><span style="color: #333333;">(</span>HttpCommandExecutor<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">165</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">service</span><span style="color: #333333;">.</span><span style="color: #0000cc;">DriverCommandExecutor</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invokeExecute</span><span style="color: #333333;">(</span>DriverCommandExecutor<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">183</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">service</span><span style="color: #333333;">.</span><span style="color: #0000cc;">DriverCommandExecutor</span><span style="color: #333333;">.</span><span style="color: #0000cc;">execute</span><span style="color: #333333;">(</span>DriverCommandExecutor<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">158</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteWebDriver</span><span style="color: #333333;">.</span><span style="color: #0000cc;">execute</span><span style="color: #333333;">(</span>RemoteWebDriver<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">543</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteWebDriver</span><span style="color: #333333;">.</span><span style="color: #0000cc;">startSession</span><span style="color: #333333;">(</span>RemoteWebDriver<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">229</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteWebDriver</span><span style="color: #333333;">.<</span>init<span style="color: #333333;">>(</span>RemoteWebDriver<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">157</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">chromium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ChromiumDriver</span><span style="color: #333333;">.<</span>init<span style="color: #333333;">>(</span>ChromiumDriver<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">101</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">chrome</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ChromeDriver</span><span style="color: #333333;">.<</span>init<span style="color: #333333;">>(</span>ChromeDriver<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">88</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">chrome</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ChromeDriver</span><span style="color: #333333;">.<</span>init<span style="color: #333333;">>(</span>ChromeDriver<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">84</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">chrome</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ChromeDriver</span><span style="color: #333333;">.<</span>init<span style="color: #333333;">>(</span>ChromeDriver<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">73</span><span style="color: #333333;">)</span>
at com<span style="color: #333333;">.</span><span style="color: #0000cc;">test</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Test2</span><span style="color: #333333;">.</span><span style="color: #0000cc;">test</span><span style="color: #333333;">(</span>Test2<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">22</span><span style="color: #333333;">)</span>
at java<span style="color: #333333;">.</span><span style="color: #0000cc;">base</span><span style="color: #333333;">/</span>jdk<span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">reflect</span><span style="color: #333333;">.</span><span style="color: #0000cc;">NativeMethodAccessorImpl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invoke0</span><span style="color: #333333;">(</span>Native Method<span style="color: #333333;">)</span>
at java<span style="color: #333333;">.</span><span style="color: #0000cc;">base</span><span style="color: #333333;">/</span>jdk<span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">reflect</span><span style="color: #333333;">.</span><span style="color: #0000cc;">NativeMethodAccessorImpl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invoke</span><span style="color: #333333;">(</span>NativeMethodAccessorImpl<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">77</span><span style="color: #333333;">)</span>
at java<span style="color: #333333;">.</span><span style="color: #0000cc;">base</span><span style="color: #333333;">/</span>jdk<span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">reflect</span><span style="color: #333333;">.</span><span style="color: #0000cc;">DelegatingMethodAccessorImpl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invoke</span><span style="color: #333333;">(</span>DelegatingMethodAccessorImpl<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">43</span><span style="color: #333333;">)</span>
at java<span style="color: #333333;">.</span><span style="color: #0000cc;">base</span><span style="color: #333333;">/</span>java<span style="color: #333333;">.</span><span style="color: #0000cc;">lang</span><span style="color: #333333;">.</span><span style="color: #0000cc;">reflect</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Method</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invoke</span><span style="color: #333333;">(</span>Method<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">568</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">MethodInvocationHelper</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invokeMethod</span><span style="color: #333333;">(</span>MethodInvocationHelper<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">133</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestInvoker</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invokeMethod</span><span style="color: #333333;">(</span>TestInvoker<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">598</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestInvoker</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invokeTestMethod</span><span style="color: #333333;">(</span>TestInvoker<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">173</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">MethodRunner</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runInSequence</span><span style="color: #333333;">(</span>MethodRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">46</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestInvoker</span>$MethodInvocationAgent<span style="color: #333333;">.</span><span style="color: #0000cc;">invoke</span><span style="color: #333333;">(</span>TestInvoker<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">824</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestInvoker</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invokeTestMethods</span><span style="color: #333333;">(</span>TestInvoker<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">146</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestMethodWorker</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invokeTestMethods</span><span style="color: #333333;">(</span>TestMethodWorker<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">146</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestMethodWorker</span><span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span>TestMethodWorker<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">128</span><span style="color: #333333;">)</span>
at java<span style="color: #333333;">.</span><span style="color: #0000cc;">base</span><span style="color: #333333;">/</span>java<span style="color: #333333;">.</span><span style="color: #0000cc;">util</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ArrayList</span><span style="color: #333333;">.</span><span style="color: #0000cc;">forEach</span><span style="color: #333333;">(</span>ArrayList<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1511</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestRunner</span><span style="color: #333333;">.</span><span style="color: #0000cc;">privateRun</span><span style="color: #333333;">(</span>TestRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">794</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestRunner</span><span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span>TestRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">596</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunner</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runTest</span><span style="color: #333333;">(</span>SuiteRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">377</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunner</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runSequentially</span><span style="color: #333333;">(</span>SuiteRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">371</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunner</span><span style="color: #333333;">.</span><span style="color: #0000cc;">privateRun</span><span style="color: #333333;">(</span>SuiteRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">332</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunner</span><span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span>SuiteRunner<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">276</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunnerWorker</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runSuite</span><span style="color: #333333;">(</span>SuiteRunnerWorker<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">53</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SuiteRunnerWorker</span><span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span>SuiteRunnerWorker<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">96</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runSuitesSequentially</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1212</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runSuitesLocally</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1134</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runSuites</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1063</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">TestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span>TestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">1031</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">AbstractRemoteTestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">run</span><span style="color: #333333;">(</span>AbstractRemoteTestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">115</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteTestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">initAndRun</span><span style="color: #333333;">(</span>RemoteTestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">251</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">testng</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteTestNG</span><span style="color: #333333;">.</span><span style="color: #0000cc;">main</span><span style="color: #333333;">(</span>RemoteTestNG<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">77</span><span style="color: #333333;">)</span>
<span style="color: #333333;">===============================================</span>
Default test
Tests <span style="color: #997700; font-weight: bold;">run:</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">Failures:</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">Skips:</span> <span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #333333;">===============================================</span>
<span style="color: #333333;">===============================================</span>
Default suite
Total tests <span style="color: #997700; font-weight: bold;">run:</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">Passes:</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">Failures:</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">Skips:</span> <span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #333333;">===============================================</span>
</pre></div>
Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-25026189548613039482023-01-14T23:01:00.001+05:302023-01-14T23:01:57.421+05:30HTML-5 Stacked Percentage Bar Chart - Advanced Properties in Jaspersoft Reprots | How to write formatter function with if else condition in Jasper Reports ?<p>For HTML-5 Stacked Percentage Bar Chart in Jaspersoft Design Studio <br />How to get percentage on bars ? When there are two percentages, for instance 0 and 100 - how to hide 0 and display only 100% on bar ? How to maintain fixed width for bars ? </p><p>Below image depicts how the visualization outputs before and after applying basic and advanced properties <br /><br />Tap on the image for better visibility. </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSaGm_FbWP6_4c2Jd2ksZWWNLTvOzrG6tnQhgdCwtYoATb5WV0as8oZYtd7RgNKB6QolHjOZIIqHSwQhstmrKkN-lxyVjAeoBPCmAOlihZohX9-MzDRd6j4gaj_qxkvZrJ9_bPkJT1oZVGp2w1qYYWXD-_EZskcuTdmBbanpI3F7hlEFr5loCLi4DgOw/s1109/HTML5StatckedBarChart.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="498" data-original-width="1109" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSaGm_FbWP6_4c2Jd2ksZWWNLTvOzrG6tnQhgdCwtYoATb5WV0as8oZYtd7RgNKB6QolHjOZIIqHSwQhstmrKkN-lxyVjAeoBPCmAOlihZohX9-MzDRd6j4gaj_qxkvZrJ9_bPkJT1oZVGp2w1qYYWXD-_EZskcuTdmBbanpI3F7hlEFr5loCLi4DgOw/s16000/HTML5StatckedBarChart.PNG" /></a></div><br /><p>Below advanced properties makes the graph to look like on the right side graph <br /><br />1) To get percentage on bars <br /> plotOptions.series.dataLabels.enabled = true</p><p>2) To get the percentage on bars with value 0 disabled and 100 having percentage symbol<br /> plotOptions.series.dataLabels.formatter=<b style="background-color: #fcff01;">"function(){ var val = this.y; if(val == 0){return '';} else return val+'%';}"</b></p><p>The equivalent java script for this is as follows. <br /></p>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">function</span>(){
<span style="color: #008800; font-weight: bold;">var</span> val <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">this</span>.y;
<span style="color: #008800; font-weight: bold;">if</span>(val <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span>){
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">''</span>;
}
<span style="color: #008800; font-weight: bold;">else</span>
<span style="color: #008800; font-weight: bold;">return</span> val<span style="color: #333333;">+</span><span style="background-color: #fff0f0;">'%'</span>;
}
</pre></div><br />3) To fix the bar width give <br /> plotOptions.bar.pointWidth=30<div><br /></div><div>(Tap on the image for better visibility)</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnVSzgtPKhNAKLM-oNoHU3Iot6uv0M-nsAlTapIuBo9piXjyyE54lpAkcnXWvV1zW9EjwJksZGP-7qKWqlWOIOAz7rFaDPCgBPjXZT1u3XywVS4DL7fVMm1rzBf1mP5164nk1zlxOPZNYRQNPVjhJgLZ_5ja_V-bsG0hSberoQwGgrlhDHoxNvQbtY8w/s1011/AdvancedProperties.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="552" data-original-width="1011" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnVSzgtPKhNAKLM-oNoHU3Iot6uv0M-nsAlTapIuBo9piXjyyE54lpAkcnXWvV1zW9EjwJksZGP-7qKWqlWOIOAz7rFaDPCgBPjXZT1u3XywVS4DL7fVMm1rzBf1mP5164nk1zlxOPZNYRQNPVjhJgLZ_5ja_V-bsG0hSberoQwGgrlhDHoxNvQbtY8w/s16000/AdvancedProperties.PNG" /></a></div><div><br /></div><div><b><i>JRXML( Works on 7.9.0 Professional Studio or later)</i></b></div><div><br /></div>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #557799;"><?xml version="1.0" encoding="UTF-8"?></span>
<span style="color: #888888;"><!-- Created with Jaspersoft Studio version 7.9.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928 --></span>
<span style="color: #007700;"><jasperReport</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://jasperreports.sourceforge.net/jasperreports"</span> <span style="color: #0000cc;">xmlns:xsi=</span><span style="background-color: #fff0f0;">"http://www.w3.org/2001/XMLSchema-instance"</span> <span style="color: #0000cc;">xsi:schemaLocation=</span><span style="background-color: #fff0f0;">"http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"HTML-5StackedPercentageBarChart.jrxml"</span> <span style="color: #0000cc;">pageWidth=</span><span style="background-color: #fff0f0;">"1200"</span> <span style="color: #0000cc;">pageHeight=</span><span style="background-color: #fff0f0;">"842"</span> <span style="color: #0000cc;">columnWidth=</span><span style="background-color: #fff0f0;">"1160"</span> <span style="color: #0000cc;">leftMargin=</span><span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">rightMargin=</span><span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">topMargin=</span><span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">bottomMargin=</span><span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">uuid=</span><span style="background-color: #fff0f0;">"831cc732-af9c-4611-9fda-cc7946b3ba40"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.data.sql.tables"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.data.defaultdataadapter"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"foodmartVeeraTraining"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"ireport.jasperserver.url"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"http://localhost:8080/jasperserver-pro/"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"ireport.jasperserver.user"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"superuser"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"ireport.jasperserver.reportUnit"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"/Training2023/HTML_5StackedPercentageBarChart"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"ireport.jasperserver.report.resource"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"/Training2023/HTML_5StackedPercentageBarChart_files/main_jrxml"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit."</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.pageHeight"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.pageWidth"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.topMargin"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.bottomMargin"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.leftMargin"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.rightMargin"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.columnWidth"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.columnSpacing"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><queryString</span> <span style="color: #0000cc;">language=</span><span style="background-color: #fff0f0;">"SQL"</span><span style="color: #007700;">></span>
<span style="color: #557799;"><![CDATA[(select 'Cate10' as Category, 'Series1' as Series, 40 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate10' as Category, 'Series2' as Series, 60 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate9' as Category, 'Series1' as Series, 10 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate9' as Category, 'Series2' as Series, 90 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate8' as Category, 'Series1' as Series, 100 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate8' as Category, 'Series2' as Series, 0 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate7' as Category, 'Series1' as Series, 45 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate7' as Category, 'Series2' as Series, 55 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate6' as Category, 'Series1' as Series, 80 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate6' as Category, 'Series2' as Series, 20 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate5' as Category, 'Series1' as Series, 15 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate5' as Category, 'Series2' as Series, 85 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate4' as Category, 'Series1' as Series, 90 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate4' as Category, 'Series2' as Series, 10 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate3' as Category, 'Series1' as Series, 25 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate3' as Category, 'Series2' as Series, 75 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate2' as Category, 'Series1' as Series, 24 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate2' as Category, 'Series2' as Series, 76 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate1' as Category, 'Series1' as Series, 34 as SeriesValue limit 1)</span>
<span style="color: #557799;">union all</span>
<span style="color: #557799;">(select 'Cate1' as Category, 'Series2' as Series, 66 as SeriesValue limit 1)]]></span>
<span style="color: #007700;"></queryString></span>
<span style="color: #007700;"><field</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"category"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.String"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.field.name"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"category"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.field.label"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"category"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></field></span>
<span style="color: #007700;"><field</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"series"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.String"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.field.name"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"series"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.field.label"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"series"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></field></span>
<span style="color: #007700;"><field</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"seriesvalue"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.Integer"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.field.name"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"seriesvalue"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.field.label"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"seriesvalue"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></field></span>
<span style="color: #007700;"><background></span>
<span style="color: #007700;"><band</span> <span style="color: #0000cc;">splitType=</span><span style="background-color: #fff0f0;">"Stretch"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></background></span>
<span style="color: #007700;"><title></span>
<span style="color: #007700;"><band</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"42"</span> <span style="color: #0000cc;">splitType=</span><span style="background-color: #fff0f0;">"Stretch"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><textField></span>
<span style="color: #007700;"><reportElement</span> <span style="color: #0000cc;">x=</span><span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">y=</span><span style="background-color: #fff0f0;">"0"</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"480"</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"42"</span> <span style="color: #0000cc;">uuid=</span><span style="background-color: #fff0f0;">"c437fc8c-354e-4dfe-b263-ff16f0e2b68d"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><textElement</span> <span style="color: #0000cc;">textAlignment=</span><span style="background-color: #fff0f0;">"Center"</span> <span style="color: #0000cc;">verticalAlignment=</span><span style="background-color: #fff0f0;">"Middle"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><font</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"13"</span> <span style="color: #0000cc;">isBold=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></textElement></span>
<span style="color: #007700;"><textFieldExpression></span><span style="color: #557799;"><![CDATA["HTML-5 Stacked Percentage Bar Chart - Before Applying Adv. Properties"]]></span><span style="color: #007700;"></textFieldExpression></span>
<span style="color: #007700;"></textField></span>
<span style="color: #007700;"><textField></span>
<span style="color: #007700;"><reportElement</span> <span style="color: #0000cc;">x=</span><span style="background-color: #fff0f0;">"600"</span> <span style="color: #0000cc;">y=</span><span style="background-color: #fff0f0;">"0"</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"480"</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"42"</span> <span style="color: #0000cc;">uuid=</span><span style="background-color: #fff0f0;">"2f7f2d3a-5aa3-4d3b-8a88-77b097b3fdd7"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><textElement</span> <span style="color: #0000cc;">textAlignment=</span><span style="background-color: #fff0f0;">"Center"</span> <span style="color: #0000cc;">verticalAlignment=</span><span style="background-color: #fff0f0;">"Middle"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><font</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"13"</span> <span style="color: #0000cc;">isBold=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></textElement></span>
<span style="color: #007700;"><textFieldExpression></span><span style="color: #557799;"><![CDATA["HTML-5 Stacked Percentage Bar Chart - After Applying Adv. Properties"]]></span><span style="color: #007700;"></textFieldExpression></span>
<span style="color: #007700;"></textField></span>
<span style="color: #007700;"></band></span>
<span style="color: #007700;"></title></span>
<span style="color: #007700;"><summary></span>
<span style="color: #007700;"><band</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"460"</span> <span style="color: #0000cc;">splitType=</span><span style="background-color: #fff0f0;">"Stretch"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.layout"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.editor.layout.FreeLayout"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.height"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"px"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><componentElement></span>
<span style="color: #007700;"><reportElement</span> <span style="color: #0000cc;">x=</span><span style="background-color: #fff0f0;">"600"</span> <span style="color: #0000cc;">y=</span><span style="background-color: #fff0f0;">"0"</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"480"</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"460"</span> <span style="color: #0000cc;">uuid=</span><span style="background-color: #fff0f0;">"31617bd0-29e7-494e-a309-e82ff9a918e9"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chart</span> <span style="color: #0000cc;">xmlns:hc=</span><span style="background-color: #fff0f0;">"http://jaspersoft.com/highcharts"</span> <span style="color: #0000cc;">xsi:schemaLocation=</span><span style="background-color: #fff0f0;">"http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd"</span> <span style="color: #0000cc;">type=</span><span style="background-color: #fff0f0;">"StackedPercentBar"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:chartSetting</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"default"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"title.text"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"credits.enabled"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"false"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"credits.href"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"credits.text"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"yAxis.title.text"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"chart.zoomType"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"xy"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"colors_customSimpleMode"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"colors"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:propertyExpression></span><span style="color: #557799;"><![CDATA[Arrays.asList("#009A17","#D64550","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1")]]></span><span style="color: #007700;"></hc:propertyExpression></span>
<span style="color: #007700;"></hc:chartProperty></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"plotOptions.series.dataLabels.enabled_customSimpleMode"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"plotOptions.series.dataLabels.enabled"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:propertyExpression></span><span style="color: #557799;"><![CDATA[true]]></span><span style="color: #007700;"></hc:propertyExpression></span>
<span style="color: #007700;"></hc:chartProperty></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"plotOptions.bar.pointWidth_customSimpleMode"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"plotOptions.bar.pointWidth"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:propertyExpression></span><span style="color: #557799;"><![CDATA[30]]></span><span style="color: #007700;"></hc:propertyExpression></span>
<span style="color: #007700;"></hc:chartProperty></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.highcharts.dataconfiguration.simple"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"plotOptions.series.dataLabels.formatter"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:propertyExpression></span><span style="color: #557799;"><![CDATA["function(){ var val = this.y; if(val == 0){return '';} else return val+'%';}"]]></span><span style="color: #007700;"></hc:propertyExpression></span>
<span style="color: #007700;"></hc:chartProperty></span>
<span style="color: #007700;"></hc:chartSetting></span>
<span style="color: #007700;"><multiAxisData></span>
<span style="color: #007700;"><multiAxisDataset></span>
<span style="color: #007700;"><dataset</span> <span style="color: #0000cc;">resetType=</span><span style="background-color: #fff0f0;">"Report"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></multiAxisDataset></span>
<span style="color: #007700;"><dataAxis</span> <span style="color: #0000cc;">axis=</span><span style="background-color: #fff0f0;">"Rows"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><axisLevel</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Level1"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><labelExpression></span><span style="color: #557799;"><![CDATA["Level Label expression"]]></span><span style="color: #007700;"></labelExpression></span>
<span style="color: #007700;"><axisLevelBucket</span> <span style="color: #0000cc;">order=</span><span style="background-color: #fff0f0;">"None"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.Comparable"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><bucketExpression></span><span style="color: #557799;"><![CDATA[$F{category}]]></span><span style="color: #007700;"></bucketExpression></span>
<span style="color: #007700;"></axisLevelBucket></span>
<span style="color: #007700;"></axisLevel></span>
<span style="color: #007700;"></dataAxis></span>
<span style="color: #007700;"><dataAxis</span> <span style="color: #0000cc;">axis=</span><span style="background-color: #fff0f0;">"Columns"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><axisLevel</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Status"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><labelExpression></span><span style="color: #557799;"><![CDATA[]]></span><span style="color: #007700;"></labelExpression></span>
<span style="color: #007700;"><axisLevelBucket</span> <span style="color: #0000cc;">order=</span><span style="background-color: #fff0f0;">"None"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.Comparable"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><bucketExpression></span><span style="color: #557799;"><![CDATA[$F{series}]]></span><span style="color: #007700;"></bucketExpression></span>
<span style="color: #007700;"></axisLevelBucket></span>
<span style="color: #007700;"></axisLevel></span>
<span style="color: #007700;"></dataAxis></span>
<span style="color: #007700;"><multiAxisMeasure</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Measure1"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.Number"</span> <span style="color: #0000cc;">calculation=</span><span style="background-color: #fff0f0;">"Nothing"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><labelExpression></span><span style="color: #557799;"><![CDATA[""]]></span><span style="color: #007700;"></labelExpression></span>
<span style="color: #007700;"><valueExpression></span><span style="color: #557799;"><![CDATA[$F{seriesvalue}]]></span><span style="color: #007700;"></valueExpression></span>
<span style="color: #007700;"></multiAxisMeasure></span>
<span style="color: #007700;"></multiAxisData></span>
<span style="color: #007700;"><hc:series</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Measure1"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></hc:chart></span>
<span style="color: #007700;"></componentElement></span>
<span style="color: #007700;"><componentElement></span>
<span style="color: #007700;"><reportElement</span> <span style="color: #0000cc;">x=</span><span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">y=</span><span style="background-color: #fff0f0;">"0"</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"480"</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"460"</span> <span style="color: #0000cc;">uuid=</span><span style="background-color: #fff0f0;">"38ecda02-7426-46af-96f2-e50ed771ee53"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.width"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"px"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.height"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"px"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></reportElement></span>
<span style="color: #007700;"><hc:chart</span> <span style="color: #0000cc;">xmlns:hc=</span><span style="background-color: #fff0f0;">"http://jaspersoft.com/highcharts"</span> <span style="color: #0000cc;">xsi:schemaLocation=</span><span style="background-color: #fff0f0;">"http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd"</span> <span style="color: #0000cc;">type=</span><span style="background-color: #fff0f0;">"StackedPercentBar"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:chartSetting</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"default"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"title.text"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"credits.enabled"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"false"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"credits.href"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"credits.text"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"yAxis.title.text"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"chart.zoomType"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"xy"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></hc:chartSetting></span>
<span style="color: #007700;"><multiAxisData></span>
<span style="color: #007700;"><multiAxisDataset></span>
<span style="color: #007700;"><dataset</span> <span style="color: #0000cc;">resetType=</span><span style="background-color: #fff0f0;">"Report"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></multiAxisDataset></span>
<span style="color: #007700;"><dataAxis</span> <span style="color: #0000cc;">axis=</span><span style="background-color: #fff0f0;">"Rows"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><axisLevel</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Level1"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><labelExpression></span><span style="color: #557799;"><![CDATA["Level Label expression"]]></span><span style="color: #007700;"></labelExpression></span>
<span style="color: #007700;"><axisLevelBucket</span> <span style="color: #0000cc;">order=</span><span style="background-color: #fff0f0;">"None"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.Comparable"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><bucketExpression></span><span style="color: #557799;"><![CDATA[$F{category}]]></span><span style="color: #007700;"></bucketExpression></span>
<span style="color: #007700;"></axisLevelBucket></span>
<span style="color: #007700;"></axisLevel></span>
<span style="color: #007700;"></dataAxis></span>
<span style="color: #007700;"><dataAxis</span> <span style="color: #0000cc;">axis=</span><span style="background-color: #fff0f0;">"Columns"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><axisLevel</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"series"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><labelExpression></span><span style="color: #557799;"><![CDATA[]]></span><span style="color: #007700;"></labelExpression></span>
<span style="color: #007700;"><axisLevelBucket</span> <span style="color: #0000cc;">order=</span><span style="background-color: #fff0f0;">"None"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.Comparable"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><bucketExpression></span><span style="color: #557799;"><![CDATA[$F{series}]]></span><span style="color: #007700;"></bucketExpression></span>
<span style="color: #007700;"></axisLevelBucket></span>
<span style="color: #007700;"></axisLevel></span>
<span style="color: #007700;"></dataAxis></span>
<span style="color: #007700;"><multiAxisMeasure</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Measure1"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.Number"</span> <span style="color: #0000cc;">calculation=</span><span style="background-color: #fff0f0;">"Nothing"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><labelExpression></span><span style="color: #557799;"><![CDATA[""]]></span><span style="color: #007700;"></labelExpression></span>
<span style="color: #007700;"><valueExpression></span><span style="color: #557799;"><![CDATA[$F{seriesvalue}]]></span><span style="color: #007700;"></valueExpression></span>
<span style="color: #007700;"></multiAxisMeasure></span>
<span style="color: #007700;"></multiAxisData></span>
<span style="color: #007700;"><hc:series</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Measure1"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></hc:chart></span>
<span style="color: #007700;"></componentElement></span>
<span style="color: #007700;"></band></span>
<span style="color: #007700;"></summary></span>
<span style="color: #007700;"></jasperReport></span>
</pre></div><div><br /></div>
ggSadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-77651467024540499432022-11-02T00:57:00.005+05:302022-11-02T00:57:55.046+05:30HTML5 Column Chart Advanced Properties in Jaspersoft Design Studio Pro<p>To display data labels above the HTML5 column/bar vizz in jasper design studio add the following advanced properties</p><p>PlotOptions > column > dataLabels </p><p><b>crop = false <br />enabled=true<br />overflow=justify </b><br /><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgjF-tigihMQJF4lIiOeW3CzrzhVBZybI2rxhGQld0i6xgG5enyLeKm013DE4IkAvsF9of2L2IzZ6igVQ8VA7foYLE2bMoM1PRqOVAj_J-sn5nwry-sGT_zmr_ux-GbaxXEKPdeKhFuxRvKOIZWPWR5U1mAfRCmKzZI50YLfFWCV_fbxZ1BaE3KE8kE4Q" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="149" data-original-width="613" height="157" src="https://blogger.googleusercontent.com/img/a/AVvXsEgjF-tigihMQJF4lIiOeW3CzrzhVBZybI2rxhGQld0i6xgG5enyLeKm013DE4IkAvsF9of2L2IzZ6igVQ8VA7foYLE2bMoM1PRqOVAj_J-sn5nwry-sGT_zmr_ux-GbaxXEKPdeKhFuxRvKOIZWPWR5U1mAfRCmKzZI50YLfFWCV_fbxZ1BaE3KE8kE4Q=w640-h157" width="640" /></a></div><br />To have fixed intervals for y-axis add the below advanced property <br /><br /><b>yAxis > tickInterval=10 </b><br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgz0P59Sohk9h88NVoSaVlkYtm1s3R6HmTCEn58RlW83E7F38AJx5_mabHqvqEPlIrTOtmX4qk4QkSHstnG5xZQw8bdKkFxMv0GUCo1ayLut1XRxg4CELLSgBWcQHUB3KgHFHW6NTlk40-kQvCL-KACzBOGilR4lWvyJT4YIc6V1YQT8s1Jaq0qQwbnNg" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="131" data-original-width="531" height="158" src="https://blogger.googleusercontent.com/img/a/AVvXsEgz0P59Sohk9h88NVoSaVlkYtm1s3R6HmTCEn58RlW83E7F38AJx5_mabHqvqEPlIrTOtmX4qk4QkSHstnG5xZQw8bdKkFxMv0GUCo1ayLut1XRxg4CELLSgBWcQHUB3KgHFHW6NTlk40-kQvCL-KACzBOGilR4lWvyJT4YIc6V1YQT8s1Jaq0qQwbnNg=w640-h158" width="640" /></a></div><br /><br /><b>Sample output of column chart </b><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEisWfjryw65-eioDFzspkPWDKOPMgfsE4BcN7ScYoxMTAFhx8w3Au1SOBuLp3BvM7Tp932Rdl1HGyazKXx-WMk5wrmcpUJXRbtxgxzSPpr9ep4xvdBGs4XaMLLnzdAJG7I-F50Q0kkNrjTKY1biVguWkpxtDfg1bAqJSoYNJgPqRHCXWyFqp5laPBJT5A" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="447" data-original-width="906" height="316" src="https://blogger.googleusercontent.com/img/a/AVvXsEisWfjryw65-eioDFzspkPWDKOPMgfsE4BcN7ScYoxMTAFhx8w3Au1SOBuLp3BvM7Tp932Rdl1HGyazKXx-WMk5wrmcpUJXRbtxgxzSPpr9ep4xvdBGs4XaMLLnzdAJG7I-F50Q0kkNrjTKY1biVguWkpxtDfg1bAqJSoYNJgPqRHCXWyFqp5laPBJT5A=w640-h316" width="640" /></a></div><b><br />JRXML ( Works in >= 7.9.0 pro only)</b><p></p>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #557799;"><?xml version="1.0" encoding="UTF-8"?></span>
<span style="color: #888888;"><!-- Created with Jaspersoft Studio version 7.9.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928 --></span>
<span style="color: #007700;"><jasperReport</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://jasperreports.sourceforge.net/jasperreports"</span> <span style="color: #0000cc;">xmlns:xsi=</span><span style="background-color: #fff0f0;">"http://www.w3.org/2001/XMLSchema-instance"</span> <span style="color: #0000cc;">xsi:schemaLocation=</span><span style="background-color: #fff0f0;">"http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"HTML5ColumnGraphAdvancedProperties"</span> <span style="color: #0000cc;">pageWidth=</span><span style="background-color: #fff0f0;">"800"</span> <span style="color: #0000cc;">pageHeight=</span><span style="background-color: #fff0f0;">"842"</span> <span style="color: #0000cc;">columnWidth=</span><span style="background-color: #fff0f0;">"760"</span> <span style="color: #0000cc;">leftMargin=</span><span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">rightMargin=</span><span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">topMargin=</span><span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">bottomMargin=</span><span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">uuid=</span><span style="background-color: #fff0f0;">"89be97f5-686b-44fb-94cc-064df05eb383"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.data.sql.tables"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.data.defaultdataadapter"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"foodmartVeeraTraining"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"ireport.jasperserver.url"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"http://localhost:8080/jasperserver-pro/"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"ireport.jasperserver.user"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"superuser"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"ireport.jasperserver.reportUnit"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"/JasperReports2021/Reports/HTML5ColumnGraphAdvancedProperties"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit."</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.pageHeight"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.pageWidth"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.topMargin"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.bottomMargin"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.leftMargin"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.rightMargin"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.columnWidth"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.unit.columnSpacing"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"pixel"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"ireport.jasperserver.report.resource"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"/JasperReports2021/Reports/HTML5ColumnGraphAdvancedProperties_files/main_jrxml"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><queryString</span> <span style="color: #0000cc;">language=</span><span style="background-color: #fff0f0;">"SQL"</span><span style="color: #007700;">></span>
<span style="color: #557799;"><![CDATA[select 'Category1' category, 22 barvalues</span>
<span style="color: #557799;">union</span>
<span style="color: #557799;">select 'Category2' , 72</span>
<span style="color: #557799;">union</span>
<span style="color: #557799;">select 'Category3' , 22</span>
<span style="color: #557799;">union</span>
<span style="color: #557799;">select 'Category4' , 38</span>
<span style="color: #557799;">union</span>
<span style="color: #557799;">select 'Category5' , 61</span>
<span style="color: #557799;">union</span>
<span style="color: #557799;">select 'Category6' , 81</span>
<span style="color: #557799;">union</span>
<span style="color: #557799;">select 'Category7' , 78</span>
<span style="color: #557799;">union</span>
<span style="color: #557799;">select 'Category8' , 50]]></span>
<span style="color: #007700;"></queryString></span>
<span style="color: #007700;"><field</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"category"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.String"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.field.name"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"category"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.field.label"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"category"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></field></span>
<span style="color: #007700;"><field</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"barvalues"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.Integer"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.field.name"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"barvalues"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><property</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"com.jaspersoft.studio.field.label"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"barvalues"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></field></span>
<span style="color: #007700;"><sortField</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"category"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><background></span>
<span style="color: #007700;"><band</span> <span style="color: #0000cc;">splitType=</span><span style="background-color: #fff0f0;">"Stretch"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></background></span>
<span style="color: #007700;"><summary></span>
<span style="color: #007700;"><band</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"425"</span> <span style="color: #0000cc;">splitType=</span><span style="background-color: #fff0f0;">"Stretch"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><componentElement></span>
<span style="color: #007700;"><reportElement</span> <span style="color: #0000cc;">x=</span><span style="background-color: #fff0f0;">"0"</span> <span style="color: #0000cc;">y=</span><span style="background-color: #fff0f0;">"78"</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"760"</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"347"</span> <span style="color: #0000cc;">uuid=</span><span style="background-color: #fff0f0;">"b68859b7-bfb6-44bd-b385-e4770743827a"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chart</span> <span style="color: #0000cc;">xmlns:hc=</span><span style="background-color: #fff0f0;">"http://jaspersoft.com/highcharts"</span> <span style="color: #0000cc;">xsi:schemaLocation=</span><span style="background-color: #fff0f0;">"http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd"</span> <span style="color: #0000cc;">type=</span><span style="background-color: #fff0f0;">"Column"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:chartSetting</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"default"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"title.text"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"credits.enabled"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"false"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"credits.href"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"credits.text"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"yAxis.title.text"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">""</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"chart.zoomType"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"xy"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"colors_customSimpleMode"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"colors"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:propertyExpression></span><span style="color: #557799;"><![CDATA[Arrays.asList("#019CDE","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1")]]></span><span style="color: #007700;"></hc:propertyExpression></span>
<span style="color: #007700;"></hc:chartProperty></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"plotOptions.column.dataLabels.enabled_customSimpleMode"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"plotOptions.column.dataLabels.enabled"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:propertyExpression></span><span style="color: #557799;"><![CDATA[true]]></span><span style="color: #007700;"></hc:propertyExpression></span>
<span style="color: #007700;"></hc:chartProperty></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"yAxis.tickInterval_customSimpleMode"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"yAxis.tickInterval"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:propertyExpression></span><span style="color: #557799;"><![CDATA[10]]></span><span style="color: #007700;"></hc:propertyExpression></span>
<span style="color: #007700;"></hc:chartProperty></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"plotOptions.column.dataLabels.crop_customSimpleMode"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"plotOptions.column.dataLabels.crop"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:propertyExpression></span><span style="color: #557799;"><![CDATA[false]]></span><span style="color: #007700;"></hc:propertyExpression></span>
<span style="color: #007700;"></hc:chartProperty></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"plotOptions.column.dataLabels.overflow"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"none"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"legend.enabled_customSimpleMode"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><hc:chartProperty</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"legend.enabled"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><hc:propertyExpression></span><span style="color: #557799;"><![CDATA[false]]></span><span style="color: #007700;"></hc:propertyExpression></span>
<span style="color: #007700;"></hc:chartProperty></span>
<span style="color: #007700;"></hc:chartSetting></span>
<span style="color: #007700;"><multiAxisData></span>
<span style="color: #007700;"><multiAxisDataset></span>
<span style="color: #007700;"><dataset</span> <span style="color: #0000cc;">resetType=</span><span style="background-color: #fff0f0;">"Report"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></multiAxisDataset></span>
<span style="color: #007700;"><dataAxis</span> <span style="color: #0000cc;">axis=</span><span style="background-color: #fff0f0;">"Rows"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><axisLevel</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Level1"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><labelExpression></span><span style="color: #557799;"><![CDATA["Level Label expression"]]></span><span style="color: #007700;"></labelExpression></span>
<span style="color: #007700;"><axisLevelBucket</span> <span style="color: #0000cc;">order=</span><span style="background-color: #fff0f0;">"None"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.Comparable"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><bucketExpression></span><span style="color: #557799;"><![CDATA[$F{category}]]></span><span style="color: #007700;"></bucketExpression></span>
<span style="color: #007700;"></axisLevelBucket></span>
<span style="color: #007700;"></axisLevel></span>
<span style="color: #007700;"></dataAxis></span>
<span style="color: #007700;"><dataAxis</span> <span style="color: #0000cc;">axis=</span><span style="background-color: #fff0f0;">"Columns"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><multiAxisMeasure</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Measure1"</span> <span style="color: #0000cc;">class=</span><span style="background-color: #fff0f0;">"java.lang.Number"</span> <span style="color: #0000cc;">calculation=</span><span style="background-color: #fff0f0;">"Nothing"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><labelExpression></span><span style="color: #557799;"><![CDATA["Percentage"]]></span><span style="color: #007700;"></labelExpression></span>
<span style="color: #007700;"><valueExpression></span><span style="color: #557799;"><![CDATA[$F{barvalues}]]></span><span style="color: #007700;"></valueExpression></span>
<span style="color: #007700;"></multiAxisMeasure></span>
<span style="color: #007700;"></multiAxisData></span>
<span style="color: #007700;"><hc:series</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"Measure1"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></hc:chart></span>
<span style="color: #007700;"></componentElement></span>
<span style="color: #007700;"><textField></span>
<span style="color: #007700;"><reportElement</span> <span style="color: #0000cc;">mode=</span><span style="background-color: #fff0f0;">"Opaque"</span> <span style="color: #0000cc;">x=</span><span style="background-color: #fff0f0;">"0"</span> <span style="color: #0000cc;">y=</span><span style="background-color: #fff0f0;">"0"</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"760"</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"70"</span> <span style="color: #0000cc;">forecolor=</span><span style="background-color: #fff0f0;">"#FFFFFF"</span> <span style="color: #0000cc;">backcolor=</span><span style="background-color: #fff0f0;">"#0071C0"</span> <span style="color: #0000cc;">uuid=</span><span style="background-color: #fff0f0;">"57041ecf-98e9-44f9-a817-17eba3daf5cc"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><textElement</span> <span style="color: #0000cc;">textAlignment=</span><span style="background-color: #fff0f0;">"Center"</span> <span style="color: #0000cc;">verticalAlignment=</span><span style="background-color: #fff0f0;">"Middle"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><font</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"16"</span> <span style="color: #0000cc;">isBold=</span><span style="background-color: #fff0f0;">"true"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></textElement></span>
<span style="color: #007700;"><textFieldExpression></span><span style="color: #557799;"><![CDATA["HTML5 Column Graph Advanced Properties in Jaspersoft Design Studio"]]></span><span style="color: #007700;"></textFieldExpression></span>
<span style="color: #007700;"></textField></span>
<span style="color: #007700;"></band></span>
<span style="color: #007700;"></summary></span>
<span style="color: #007700;"></jasperReport></span>
</pre></div><br />I hope you found this helpful. <br />For Jaspersoft or QA Automation video tutorials refer <a href="https://jasper-bi-suite.blogspot.com/p/video-tutorials.html" rel="nofollow" target="_blank">this page.</a>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-51819521894417105132022-09-14T00:42:00.010+05:302022-09-14T01:54:52.355+05:30 Extent Report for Cucumber 7 (Extent reports for Cucumber-JVM version 7) | Cucumber, TestNG, Selenium Java , Maven This post outlines about - how to integrate Extent Report for cucumber 7 that is integrated with TestNG, Selenium Java and Maven. <br /><br />You can clone the complete example from this <a href="https://github.com/sadakar/CucumberTestNGSeleniumExecutableJarWithExtentReports.git" rel="nofollow" target="_blank">GitHub</a> repo or <a href="https://drive.google.com/file/d/1KajUZQKcgOnmABsAAocbXkczDRy-ch6t/view?usp=sharing" rel="nofollow" target="_blank">down load the zip archive file here</a>. <br /><br /><i>This code has two cucumber scenarios independent of each other but uses the same Background in the feature files. And, I've deliberately failing these scenarios to view the screen shot attachments in Extent Report(Spark Report). <br />Update this piece of yellow highlighted string from this statement in HRMLoginPage.java so both the scenarios will get succeeded. </i><div><i><br />driver.findElement(By.xpath("<span style="background-color: #fcff01;">BAD</span>//body/div[@id='app']/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]/form[1]/div[1]/div[1]/div[2]/input[1]")).sendKeys(cells.get(0).get(0));</i><br /><br /><br />You could also refer this <b>no voice video walkthrough tutorial.</b> <br /><iframe allowfullscreen="" class="BLOG_video_class" height="442" src="https://www.youtube.com/embed/V--8Fq_I75s" width="684" youtube-src-id="V--8Fq_I75s"></iframe><br /><b>NOTE : </b><br />The best practice is to keep the code under src/test/java or src/test/resources but this makes hard to have the executable jar crated, so code should reside under src/main/java or src/main/resources. <br /><br /><b><span style="color: #073763;">Project outline:</span></b><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbvM44dyIhotWhq_i6MbwDbDjjJOvT_OAUVoLs0SVx0Q2HMJB8oziI7a7bPllSVcyHSCHf_uwHNLxMi18D03AX8ZC-THXfN7pkAHJO4BOtnL-mlU59hz0Rs-SImB-MauQ37aumhtFQ1FBOO2I5xDtRqwCf1jLsxVKPMe7J6UjHi6WPlL2_IbgC_PExBg/s912/project.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="912" data-original-width="717" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbvM44dyIhotWhq_i6MbwDbDjjJOvT_OAUVoLs0SVx0Q2HMJB8oziI7a7bPllSVcyHSCHf_uwHNLxMi18D03AX8ZC-THXfN7pkAHJO4BOtnL-mlU59hz0Rs-SImB-MauQ37aumhtFQ1FBOO2I5xDtRqwCf1jLsxVKPMe7J6UjHi6WPlL2_IbgC_PExBg/s16000/project.png" /></a><br /><br /><div><br /></div><div><span style="color: #073763;"><b>Step 1: Add the following dependency to the pom.xml file</b></span></div>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #007700;"><dependency></span>
<span style="color: #007700;"><groupId></span>tech.grasshopper<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>extentreports-cucumber7-adapter<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>1.7.0<span style="color: #007700;"></version></span>
<span style="color: #007700;"></dependency></span>
</pre></div><br /><b><span style="color: #073763;">Step 2 : Add the extent cucumber adapter as plugin in the @CucumberOptions</span><br /></b> Cucumber options are normally given in the Cucumber Test Runner class, for instance in <b><i>RunCucumberTest. java<br /></i></b><br /><!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white;">plugin </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"pretty"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"json:target/cucumber-reports/cucumber.json"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"html:target/cucumber-reports/cucumberreport.html"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span><b style="background-color: #fcff01;">"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"</b></span><span style="background-color: white; color: #333333;">},</span><span style="background-color: white;">
</span></pre></div><br /><span style="color: #073763;"><b> Step 3 : Create extent.properties file in src/main/resources and add below properties</b></span><div><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #0000cc;">extent.reporter.spark.start</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">true </span>
<span style="color: #0000cc;">extent.reporter.spark.out</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">target/SparkReport/Spark.html </span>
<span style="color: #0000cc;">screenshot.dir</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">target/screenshots/ </span>
<span style="color: #0000cc;">screenshot.rel.path</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">../screenshots/ </span>
</pre></div><br />If we want to generate the extent report(say Spark report) in an executable jar file, add the plugin in main method as shown in below BasePage.java. <br />When run the cucumber scenarios from jar file , the jar generates "target" folder and inside it we can find the Extent Report that is Spark.html<br /><b>BasePage.java</b><br />
<!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white; color: #008800; font-weight: bold;">package</span><span style="background-color: white;"> com</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">sadakar</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">common</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">org.openqa.selenium.WebDriver</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">io.cucumber.core.cli.Main</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">class</span><span style="background-color: white;"> </span><span style="background-color: white; color: #bb0066; font-weight: bold;">BasePage</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">static</span><span style="background-color: white;"> WebDriver driver</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">static</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333399; font-weight: bold;">void</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0066bb; font-weight: bold;">main</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">String args</span><span style="background-color: white; color: #333333;">[])</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">throws</span><span style="background-color: white;"> Throwable </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">try</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
Main</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">main</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> String</span><span style="background-color: white; color: #333333;">[]</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"-g"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: #fff0f0;">"com.sadakar.common"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"-g"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: #fff0f0;">"com.sadakar.stepdefinitions"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"-g"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: #fff0f0;">"com.sadakar.testng.runner"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"classpath:features"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"-t"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: #fff0f0;">"@SmokeTest"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"-p"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"pretty"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"-p"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"json:target/cucumber-reports/cucumber.json"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"-p"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"html:target/cucumber-reports/cucumberreport.html"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;">
</span><span style="background-color: #fcff01;"><b> <span>"-p"</span><span style="color: #333333;">,</span><span>"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"</span><span style="color: #333333;">,</span></b></span><span style="background-color: white;">
</span><span style="background-color: #fff0f0;">"-m"</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">catch</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">Exception e</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
e</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">printStackTrace</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"Main method exception : "</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">+</span><span style="background-color: white;"> e</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span></pre></div><br /><br />Save the project and run it as TestNG from eclipse or you could run the scenarios from the executable jar file and analyze the reports generated in "target" folder. <br /><br />The Extent Report(Spark.html) with successful execution should look as shown in below image. <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL94A8Dmn_p9wrRAVfnY6PRlIXRvFdlVNQwmoJwZrLxOmVSHEuBAwS_6bwyeiWVPyzDFWMalJ-6luL4gnihVBd6F_3HUIbhUmCEkwnAhnM8TjKR2zYAnX6-U2Vo9VhY9NykIWqGs9QrGxDjjrh41Krt5sXrqSOcgWggbcQN1oAQR9b0Dz2lvRhhZqCpQ/s1297/1.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="460" data-original-width="1297" height="226" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL94A8Dmn_p9wrRAVfnY6PRlIXRvFdlVNQwmoJwZrLxOmVSHEuBAwS_6bwyeiWVPyzDFWMalJ-6luL4gnihVBd6F_3HUIbhUmCEkwnAhnM8TjKR2zYAnX6-U2Vo9VhY9NykIWqGs9QrGxDjjrh41Krt5sXrqSOcgWggbcQN1oAQR9b0Dz2lvRhhZqCpQ/w640-h226/1.png" width="640" /></a><div><br /></div><div><br /></div><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZtDnbpz59vjZEuk9dhKnypgXUcl3tfynhTNPmyYQe-8HXUJS-U-Uqahdh_GuIpa_01SZHk0m46sfQx91WdRb0y6A1Yon3k2jTd-9e4E8IQwqUJIu48l8pv_HMOffbwIxBTITDmtAQ0B1c-ENj8m1QOHnAauQrgXVRxMcjrk5BCY5Jn1fRVnodw1Oz5g/s1298/2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="615" data-original-width="1298" height="304" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZtDnbpz59vjZEuk9dhKnypgXUcl3tfynhTNPmyYQe-8HXUJS-U-Uqahdh_GuIpa_01SZHk0m46sfQx91WdRb0y6A1Yon3k2jTd-9e4E8IQwqUJIu48l8pv_HMOffbwIxBTITDmtAQ0B1c-ENj8m1QOHnAauQrgXVRxMcjrk5BCY5Jn1fRVnodw1Oz5g/w640-h304/2.png" width="640" /></a></div><div><br /></div><br /><div><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCijkh6bM1lTCfX0HZbf-LYbuK3VS4A8rsE3heY3kIgN09rqCDv2oeheKyqkcCEtsPb_R1PQAJdc-aZVW3lHkAXvMixWJ9-5dQiRAzETDwDF7jzIVEXyUp27HPhUzCeNQqm3KQa5adJJBKC2JQFsz7OAKUBm6uURJcLHLlXfAM4_Bx-dtP9tpYLczqqg/s1867/3.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="943" data-original-width="1867" height="324" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCijkh6bM1lTCfX0HZbf-LYbuK3VS4A8rsE3heY3kIgN09rqCDv2oeheKyqkcCEtsPb_R1PQAJdc-aZVW3lHkAXvMixWJ9-5dQiRAzETDwDF7jzIVEXyUp27HPhUzCeNQqm3KQa5adJJBKC2JQFsz7OAKUBm6uURJcLHLlXfAM4_Bx-dtP9tpYLczqqg/w640-h324/3.png" width="640" /></a></div><div><br /><b><span style="color: #073763;">Now, what if you want to attach screen shots for the failed scenarios ? </span></b><br />The location is given the extent.properties file <br /><pre style="line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"><span style="color: #0000cc;">screenshot.dir</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">target/screenshots/ </span>
<span style="color: #0000cc;">screenshot.rel.path</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">../screenshots/ </span></pre></div><div><br /></div><div>In order to get the screen shots , add below piece of code in Cucumber @After hook with order=2 since the order=1 is used to quit the driver after each scenario. This order plays a vital role in terms of attaching screen short after a failed scenario. </div><div><br /><pre style="line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"><b><span style="color: #008800;">if</span> <span style="color: #333333;">((</span>scenario<span style="color: #333333;">.</span><span style="color: #0000cc;">isFailed</span><span style="color: #333333;">()))</span> <span style="color: #333333;">{</span>
<span style="color: #008800;">final</span> <span style="color: #333399;">byte</span><span style="color: #333333;">[]</span> screenshot <span style="color: #333333;">=</span> <span style="color: #333333;">((</span>TakesScreenshot<span style="color: #333333;">)</span> driver<span style="color: #333333;">).</span><span style="color: #0000cc;">getScreenshotAs</span><span style="color: #333333;">(</span>OutputType<span style="color: #333333;">.</span><span style="color: #0000cc;">BYTES</span><span style="color: #333333;">);</span>
scenario<span style="color: #333333;">.</span><span style="color: #0000cc;">attach</span><span style="color: #333333;">(</span>screenshot<span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"image/png"</span><span style="color: #333333;">,</span> scenario<span style="color: #333333;">.</span><span style="color: #0000cc;">getName</span><span style="color: #333333;">());</span>
<span style="color: #333333;">}</span></b></pre></div><div><br /></div>
<!--HTML generated using hilite.me--><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="background-color: white; color: #008800; font-weight: bold;">package</span><span style="background-color: white;"> com</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">sadakar</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">common</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">java.time.Duration</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">org.openqa.selenium.OutputType</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">org.openqa.selenium.TakesScreenshot</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">org.openqa.selenium.chrome.ChromeDriver</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">io.cucumber.java.After</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">io.cucumber.java.Before</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">import</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0e84b5; font-weight: bold;">io.cucumber.java.Scenario</span><span style="background-color: white; color: #333333;">;</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">class</span><span style="background-color: white;"> </span><span style="background-color: white; color: #bb0066; font-weight: bold;">Hooks</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">extends</span><span style="background-color: white;"> BasePage </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
</span><span style="background-color: white; color: #555555; font-weight: bold;">@Before</span><span style="background-color: white;"> </span><span style="background-color: white; color: #888888;">//Cucumber hook - runs for each scenario</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">static</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333399; font-weight: bold;">void</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0066bb; font-weight: bold;">setupDriver</span><span style="background-color: white; color: #333333;">()</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">throws</span><span style="background-color: white;"> InterruptedException </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">setProperty</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"webdriver.chrome.driver"</span><span style="background-color: white; color: #333333;">,</span><span style="background-color: white;"> </span><span style="background-color: #fff0f0;">"D:\\chromedriver.exe"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
driver </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">new</span><span style="background-color: white;"> ChromeDriver</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;">
driver</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">manage</span><span style="background-color: white; color: #333333;">().</span><span style="background-color: white; color: #0000cc;">window</span><span style="background-color: white; color: #333333;">().</span><span style="background-color: white; color: #0000cc;">maximize</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;">
driver</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">get</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"https://opensource-demo.orangehrmlive.com/web/index.php/auth/login"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
driver</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">manage</span><span style="background-color: white; color: #333333;">().</span><span style="background-color: white; color: #0000cc;">timeouts</span><span style="background-color: white; color: #333333;">().</span><span style="background-color: white; color: #0000cc;">implicitlyWait</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">Duration</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">ofSeconds</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white; color: #0000dd; font-weight: bold;">30</span><span style="background-color: white; color: #333333;">));</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span><span style="background-color: white; color: #555555; font-weight: bold;">@After</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">order</span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white; color: #0000dd; font-weight: bold;">1</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;"> </span><span style="background-color: white; color: #888888;">//Cucumber hook - runs for each scenario</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">static</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333399; font-weight: bold;">void</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0066bb; font-weight: bold;">quitDriver</span><span style="background-color: white; color: #333333;">()</span><span style="background-color: white;"> </span><span style="background-color: white; color: #008800; font-weight: bold;">throws</span><span style="background-color: white;"> Exception </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
driver</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">quit</span><span style="background-color: white; color: #333333;">();</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span><span style="background-color: white; color: #555555; font-weight: bold;">@After</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">order </span><span style="background-color: white; color: #333333;">=</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0000dd; font-weight: bold;">2</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;"> </span><span style="background-color: white; color: #888888;">// Cucumber After Hook with order 1</span><span style="background-color: white;">
</span><span style="background-color: white; color: #008800; font-weight: bold;">public</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333399; font-weight: bold;">void</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0066bb; font-weight: bold;">takeScreenShotOnFailedScenario</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: white;">Scenario scenario</span><span style="background-color: white; color: #333333;">)</span><span style="background-color: white;"> </span><span style="background-color: white; color: #333333;">{</span><span style="background-color: white;">
System</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">out</span><span style="background-color: white; color: #333333;">.</span><span style="background-color: white; color: #0000cc;">println</span><span style="background-color: white; color: #333333;">(</span><span style="background-color: #fff0f0;">"Taking screenshot from Cucumber After hook with order=2 if the scenario fails"</span><span style="background-color: white; color: #333333;">);</span><span style="background-color: white;">
</span><span style="background-color: #fcff01;"><span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>scenario<span style="color: #333333;">.</span><span style="color: #0000cc;">isFailed</span><span style="color: #333333;">()))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">final</span> <span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">[]</span> screenshot <span style="color: #333333;">=</span> <span style="color: #333333;">((</span>TakesScreenshot<span style="color: #333333;">)</span> driver<span style="color: #333333;">).</span><span style="color: #0000cc;">getScreenshotAs</span><span style="color: #333333;">(</span>OutputType<span style="color: #333333;">.</span><span style="color: #0000cc;">BYTES</span><span style="color: #333333;">);</span>
scenario<span style="color: #333333;">.</span><span style="color: #0000cc;">attach</span><span style="color: #333333;">(</span>screenshot<span style="color: #333333;">,</span> <span>"image/png"</span><span style="color: #333333;">,</span> scenario<span style="color: #333333;">.</span><span style="color: #0000cc;">getName</span><span style="color: #333333;">());</span>
<span style="color: #333333;">}</span></span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span><span style="background-color: white; color: #333333;">}</span><span style="background-color: white;">
</span></pre></div>
<div><br /></div><div>The same code base above is given to have bad login so it will fail both the scenarios and so the <b>Sprak.html</b> look like below with the screen shot attached. </div><div><br /></div><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5OXDoeYdiGvxDxwmiX3tpjgf4-spdhUkHW5lheKGyyqJNbzpKJ6NB3uWAQlUVD11lCjsZk_FDN7xT1K_RquqlJdta6p5Qc9PLOLxuVgN-FTfw4wmm9r0Zh87HTNGxQlc9hfuTUQ8zbgXqIsgLE9pT0048vq7AyB_he2JixoTFioNnoaG0S00ajpEjMQ/s1915/failed.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="892" data-original-width="1915" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5OXDoeYdiGvxDxwmiX3tpjgf4-spdhUkHW5lheKGyyqJNbzpKJ6NB3uWAQlUVD11lCjsZk_FDN7xT1K_RquqlJdta6p5Qc9PLOLxuVgN-FTfw4wmm9r0Zh87HTNGxQlc9hfuTUQ8zbgXqIsgLE9pT0048vq7AyB_he2JixoTFioNnoaG0S00ajpEjMQ/w640-h298/failed.png" width="640" /></a></div><br /><div><br /><br /><div style="text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidEijra3rg1wHwXh-RdnJhddtjtav1Xb7E2Op1BJ21HBhz3rmdkMcg7vqQ_mKVtV-zKYZEkez9ALmA5PqcTGMaE2fQeMgSeCA-l5sRM-T-sSxBTxzP1IlK8SzPnhZyx5yRAjk5jIkUp5QO5RGdtZzWcvmfJQrlXaX5jyCcuJGZBzf-4IlhXWP4FMe_PQ/s1918/failed2.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="957" data-original-width="1918" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidEijra3rg1wHwXh-RdnJhddtjtav1Xb7E2Op1BJ21HBhz3rmdkMcg7vqQ_mKVtV-zKYZEkez9ALmA5PqcTGMaE2fQeMgSeCA-l5sRM-T-sSxBTxzP1IlK8SzPnhZyx5yRAjk5jIkUp5QO5RGdtZzWcvmfJQrlXaX5jyCcuJGZBzf-4IlhXWP4FMe_PQ/w640-h320/failed2.png" width="640" /></a></div><br /><b>References: </b><br /><a href="https://github.com/grasshopper7/extentreports-cucumber7-adapter">https://github.com/grasshopper7/extentreports-cucumber7-adapter</a><br /><br />That's all we have to do to integrate Extent Report with cucumber 7. <br />I hope you found this demo is useful! Keep an eye on this space for interesting automation updates and do subscribe the YouTube channel. </div></div></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br />Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-58234482358866960342022-09-10T20:49:00.006+05:302023-12-22T11:52:14.238+05:30How to run cucumber scenarios from executable jar ? | Selenium Java, TestNG, Cucumber, Maven | How to use io.cucumber.core.cli.Main.main() ?<p> In this blog post , we will learn majorly the following topics. <br /><br />1. How to create an executable jar for cucumber+selenium+testng+maven project ?<br />2. How to run scenarios from generated jar ? <br /><br />To create an executable jar for maven project there are many jar plug-in's available in the maven space. <br />In this example, I'd like to demonstrate it using <b>maven-assembly-plugin. </b></p><p>The demo project for HRM application can be found at <a href="https://github.com/sadakar/CucumberTestNGSeleniumExecutableJar.git" rel="nofollow" target="_blank">GitHub </a> or <a href="https://drive.google.com/file/d/14eetY-EHemDlTeT93y-dOYTIcVcF8q6Q/view?usp=sharing" rel="nofollow" target="_blank">download this maven zip file</a></p><p>You could also watch this no voice video tutorial for quick references <br />(Pls do subscribe for more automation updates)<br /><br /><span style="background-color: #cfe2f3;"><b>java -jar </b><b>-Dcucumber.filter.tags="@HRMLogin" </b><b><i>CucumberTestNGSeleniumExecutableJar-0.0.1-SNAPSHOT-jar-with-dependencies.jar</i> </b></span><br /><br /><iframe allowfullscreen="" class="BLOG_video_class" height="293" src="https://www.youtube.com/embed/fcF_CRcEPHU" width="514" youtube-src-id="fcF_CRcEPHU"></iframe></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFjryxKET_i4ri0libAiircxLI8zUP8KMPXXGm4d70mj7bRg689LF1RVCAx7HsO4TlY6KF9B2fvXE3kLFQogadvlMo5gBIlI72QB6e4LCXKPjLrrNT2jiCWVP7zCwr5N_2MtZAFJUGBYyw6QDJlhvS55KLDBdDLl_1lbeSsnwF7QwBuMXeIKNwjsvmJw/s917/executable%20jar.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="917" data-original-width="616" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFjryxKET_i4ri0libAiircxLI8zUP8KMPXXGm4d70mj7bRg689LF1RVCAx7HsO4TlY6KF9B2fvXE3kLFQogadvlMo5gBIlI72QB6e4LCXKPjLrrNT2jiCWVP7zCwr5N_2MtZAFJUGBYyw6QDJlhvS55KLDBdDLl_1lbeSsnwF7QwBuMXeIKNwjsvmJw/s16000/executable%20jar.png" /></a></div><br /><div><br /></div>Now, let's see the core part that we start with pom.xml<br />We need to have the <b>maven-assembly-plugin</b> is given the pom file, i.e., add below piece of code in the pom.xml file. <br /><br /><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #007700;"><plugin></span>
<span style="color: #007700;"><groupId></span>org.apache.maven.plugins<span style="color: #007700;"></groupId></span>
<span style="color: #007700;"><artifactId></span>maven-assembly-plugin<span style="color: #007700;"></artifactId></span>
<span style="color: #007700;"><version></span>3.1.1<span style="color: #007700;"></version></span>
<span style="color: #007700;"><configuration></span>
<span style="color: #007700;"><archive></span>
<span style="color: #007700;"><manifest></span>
<span style="color: #007700;"><addClasspath></span>true<span style="color: #007700;"></addClasspath></span>
<span style="color: #007700;"><mainClass></span>com.sadakar.common.BasePage<span style="color: #007700;"></mainClass></span>
<span style="color: #007700;"></manifest></span>
<span style="color: #007700;"><manifestEntries></span>
<span style="color: #007700;"><Class-Path></span>.<span style="color: #007700;"></Class-Path></span>
<span style="color: #007700;"></manifestEntries></span>
<span style="color: #007700;"></archive></span>
<span style="color: #007700;"><descriptorRefs></span>
<span style="color: #007700;"><descriptorRef></span>jar-with-dependencies<span style="color: #007700;"></descriptorRef></span>
<span style="color: #007700;"></descriptorRefs></span>
<span style="color: #007700;"></configuration></span>
<span style="color: #007700;"><executions></span>
<span style="color: #007700;"><execution></span>
<span style="color: #007700;"><id></span>make-assembly<span style="color: #007700;"></id></span>
<span style="color: #007700;"><phase></span>package<span style="color: #007700;"></phase></span>
<span style="color: #007700;"><goals></span>
<span style="color: #007700;"><goal></span>single<span style="color: #007700;"></goal></span>
<span style="color: #007700;"></goals></span>
<span style="color: #007700;"></execution></span>
<span style="color: #007700;"></executions></span>
<span style="color: #007700;"></plugin></span>
</pre></div>
<p></p>
In a java class, using "main" method, we need to pass the glue code, tags, plug-ins and etc that are related to cucumber as arguments. <br />For example, I've used, <b>BasePage.java</b> class that should contain normal "main" method and inside it use Main.main(....) to pass cucumber arguments so the scenarios based on tags would be runnable from command line. <br />import package : <b>import io.cucumber.core.cli.Main;</b> in the <b>BasePage.java</b> class and the passing of arguments are shown in below class. <div><br /><pre style="line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"><span style="color: #bb0066; font-weight: bold;">BasePage.java</span></pre></div>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">package</span> com<span style="color: #333333;">.</span><span style="color: #0000cc;">sadakar</span><span style="color: #333333;">.</span><span style="color: #0000cc;">common</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">org.openqa.selenium.WebDriver</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">io.cucumber.core.cli.Main</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">BasePage</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> WebDriver driver<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">main</span><span style="color: #333333;">(</span>String args<span style="color: #333333;">[])</span> <span style="color: #008800; font-weight: bold;">throws</span> Throwable <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
Main<span style="color: #333333;">.</span><span style="color: #0000cc;">main</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]</span> <span style="color: #333333;">{</span>
<span style="background-color: #fff0f0;">"-g"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"com.sadakar.common"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-g"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"com.sadakar.stepdefinitions"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-g"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"com.sadakar.testng.runner"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"classpath:features"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-t"</span><span style="color: #333333;">,</span><span style="background-color: #fff0f0;">"@HRMLogin"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-p"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"pretty"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-p"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"json:target/cucumber-reports/cucumber.json"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-p"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"html:target/cucumber-reports/cucumberreport.html"</span><span style="color: #333333;">,</span>
<span style="background-color: #fff0f0;">"-m"</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>Exception e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
e<span style="color: #333333;">.</span><span style="color: #0000cc;">printStackTrace</span><span style="color: #333333;">();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Main method exception : "</span> <span style="color: #333333;">+</span> e<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre></div><br />In eclipse, build the project using below command: <br /><br />Ensure that any open folders, command prompts, chrome drivers in task manager are all closed.<br />Clean the project and then build it. <br /><br /><b>clean package assembly:single -Dmaven.test.skip=true</b><br /><br />Using <b>-Dmaven.test.skip=true </b>option we can skip the tests while the project builds! <b><br /><br /><br /><span style="color: #073763;"><i>Click on the images to view them in gallery mode so the content provided is clear! </i></span><br /><br /></b><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNhksIU8jbI0nzhdwGxsGc6bi_g-6KDOgwYG196DKniB25yQk9yvFrgG43oGdWIm-xe-c8qqd_ZRa4B8il9i1focIyHxtTChpJAW1n0X1UrzhFDguEEk34YccRrCfNJMRxZM15IjoAfkiDmAd8bGDnNXsfWApCHfEDnQrFio4FsbzbxTI9dvZJgmFfuA/s690/build.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="690" data-original-width="678" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNhksIU8jbI0nzhdwGxsGc6bi_g-6KDOgwYG196DKniB25yQk9yvFrgG43oGdWIm-xe-c8qqd_ZRa4B8il9i1focIyHxtTChpJAW1n0X1UrzhFDguEEk34YccRrCfNJMRxZM15IjoAfkiDmAd8bGDnNXsfWApCHfEDnQrFio4FsbzbxTI9dvZJgmFfuA/w393-h400/build.png" width="393" /></a></div><br />This is how the log looks like when the build is in progress and is completed. <br />
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #997700; font-weight: bold;">SLF4J:</span> Class path contains multiple SLF4J bindings<span style="color: #333333;">.</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Found binding in <span style="color: #333333;">[</span><span style="color: #997700; font-weight: bold;">jar:file:</span><span style="color: #333333;">/</span><span style="color: #997700; font-weight: bold;">D:</span><span style="color: #333333;">/</span>softwares<span style="color: #333333;">/</span>Eclipse<span style="color: #333333;">/</span>eclipse<span style="color: #333333;">-</span>java<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">2021</span><span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">09</span><span style="color: #333333;">-</span>R<span style="color: #333333;">-</span>win32<span style="color: #333333;">-</span>x86_64<span style="color: #333333;">/</span>eclipse<span style="color: #333333;">/</span>plugins<span style="color: #333333;">/</span>org<span style="color: #333333;">.</span><span style="color: #0000cc;">eclipse</span><span style="color: #333333;">.</span><span style="color: #0000cc;">m2e</span><span style="color: #333333;">.</span><span style="color: #0000cc;">maven</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runtime</span><span style="color: #333333;">.</span><span style="color: #0000cc;">slf4j</span><span style="color: #333333;">.</span><span style="color: #0000cc;">simple_1</span><span style="color: #333333;">.</span><span style="color: #6600ee; font-weight: bold;">18.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">20210618</span><span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">2246</span><span style="color: #333333;">/</span>jars<span style="color: #333333;">/</span>slf4j<span style="color: #333333;">-</span>simple<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.7</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span><span style="color: #333333;">!/</span>org<span style="color: #333333;">/</span>slf4j<span style="color: #333333;">/</span>impl<span style="color: #333333;">/</span>StaticLoggerBinder<span style="color: #333333;">.</span><span style="color: #0000cc;">class</span><span style="color: #333333;">]</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Found binding in <span style="color: #333333;">[</span><span style="color: #997700; font-weight: bold;">file:</span><span style="color: #333333;">/</span><span style="color: #997700; font-weight: bold;">D:</span><span style="color: #333333;">/</span>softwares<span style="color: #333333;">/</span>Eclipse<span style="color: #333333;">/</span>eclipse<span style="color: #333333;">-</span>java<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">2021</span><span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">09</span><span style="color: #333333;">-</span>R<span style="color: #333333;">-</span>win32<span style="color: #333333;">-</span>x86_64<span style="color: #333333;">/</span>eclipse<span style="color: #333333;">/</span>configuration<span style="color: #333333;">/</span>org<span style="color: #333333;">.</span><span style="color: #0000cc;">eclipse</span><span style="color: #333333;">.</span><span style="color: #0000cc;">osgi</span><span style="color: #333333;">/</span><span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">/</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">/.</span><span style="color: #0000cc;">cp</span><span style="color: #333333;">/</span>org<span style="color: #333333;">/</span>slf4j<span style="color: #333333;">/</span>impl<span style="color: #333333;">/</span>StaticLoggerBinder<span style="color: #333333;">.</span><span style="color: #0000cc;">class</span><span style="color: #333333;">]</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> See <span style="color: #997700; font-weight: bold;">http:</span><span style="color: #888888;">//www.slf4j.org/codes.html#multiple_bindings for an explanation.</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Actual binding is of type <span style="color: #333333;">[</span>org<span style="color: #333333;">.</span><span style="color: #0000cc;">slf4j</span><span style="color: #333333;">.</span><span style="color: #0000cc;">impl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SimpleLoggerFactory</span><span style="color: #333333;">]</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Class path contains multiple SLF4J bindings<span style="color: #333333;">.</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Found binding in <span style="color: #333333;">[</span><span style="color: #997700; font-weight: bold;">jar:file:</span><span style="color: #333333;">/</span><span style="color: #997700; font-weight: bold;">D:</span><span style="color: #333333;">/</span>softwares<span style="color: #333333;">/</span>Eclipse<span style="color: #333333;">/</span>eclipse<span style="color: #333333;">-</span>java<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">2021</span><span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">09</span><span style="color: #333333;">-</span>R<span style="color: #333333;">-</span>win32<span style="color: #333333;">-</span>x86_64<span style="color: #333333;">/</span>eclipse<span style="color: #333333;">/</span>plugins<span style="color: #333333;">/</span>org<span style="color: #333333;">.</span><span style="color: #0000cc;">eclipse</span><span style="color: #333333;">.</span><span style="color: #0000cc;">m2e</span><span style="color: #333333;">.</span><span style="color: #0000cc;">maven</span><span style="color: #333333;">.</span><span style="color: #0000cc;">runtime</span><span style="color: #333333;">.</span><span style="color: #0000cc;">slf4j</span><span style="color: #333333;">.</span><span style="color: #0000cc;">simple_1</span><span style="color: #333333;">.</span><span style="color: #6600ee; font-weight: bold;">18.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">20210618</span><span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">2246</span><span style="color: #333333;">/</span>jars<span style="color: #333333;">/</span>slf4j<span style="color: #333333;">-</span>simple<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.7</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span><span style="color: #333333;">!/</span>org<span style="color: #333333;">/</span>slf4j<span style="color: #333333;">/</span>impl<span style="color: #333333;">/</span>StaticLoggerBinder<span style="color: #333333;">.</span><span style="color: #0000cc;">class</span><span style="color: #333333;">]</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Found binding in <span style="color: #333333;">[</span><span style="color: #997700; font-weight: bold;">file:</span><span style="color: #333333;">/</span><span style="color: #997700; font-weight: bold;">D:</span><span style="color: #333333;">/</span>softwares<span style="color: #333333;">/</span>Eclipse<span style="color: #333333;">/</span>eclipse<span style="color: #333333;">-</span>java<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">2021</span><span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">09</span><span style="color: #333333;">-</span>R<span style="color: #333333;">-</span>win32<span style="color: #333333;">-</span>x86_64<span style="color: #333333;">/</span>eclipse<span style="color: #333333;">/</span>configuration<span style="color: #333333;">/</span>org<span style="color: #333333;">.</span><span style="color: #0000cc;">eclipse</span><span style="color: #333333;">.</span><span style="color: #0000cc;">osgi</span><span style="color: #333333;">/</span><span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">/</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">/.</span><span style="color: #0000cc;">cp</span><span style="color: #333333;">/</span>org<span style="color: #333333;">/</span>slf4j<span style="color: #333333;">/</span>impl<span style="color: #333333;">/</span>StaticLoggerBinder<span style="color: #333333;">.</span><span style="color: #0000cc;">class</span><span style="color: #333333;">]</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> See <span style="color: #997700; font-weight: bold;">http:</span><span style="color: #888888;">//www.slf4j.org/codes.html#multiple_bindings for an explanation.</span>
<span style="color: #997700; font-weight: bold;">SLF4J:</span> Actual binding is of type <span style="color: #333333;">[</span>org<span style="color: #333333;">.</span><span style="color: #0000cc;">slf4j</span><span style="color: #333333;">.</span><span style="color: #0000cc;">impl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">SimpleLoggerFactory</span><span style="color: #333333;">]</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Scanning <span style="color: #008800; font-weight: bold;">for</span> projects<span style="color: #333333;">...</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">--<</span> <span style="color: #997700; font-weight: bold;">CucumberTestNGSeleniumExecutableJar:</span>CucumberTestNGSeleniumExecutableJar <span style="color: #333333;">>--</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Building CucumberTestNGSeleniumExecutableJar <span style="color: #6600ee; font-weight: bold;">0.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">-</span>SNAPSHOT
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">--------------------------------[</span> jar <span style="color: #333333;">]---------------------------------</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">---</span> maven<span style="color: #333333;">-</span>clean<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">plugin:</span><span style="color: #6600ee; font-weight: bold;">2.5</span><span style="color: #333333;">:</span>clean <span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">-</span>clean<span style="color: #333333;">)</span> <span style="background-color: #ffaaaa; color: red;">@</span> CucumberTestNGSeleniumExecutableJar <span style="color: #333333;">---</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Deleting <span style="color: #997700; font-weight: bold;">C:</span><span style="background-color: #ffaaaa; color: red;">\</span>Users<span style="background-color: #ffaaaa; color: red;">\</span>sadakarp<span style="background-color: #ffaaaa; color: red;">\</span>eclipse<span style="color: #333333;">-</span>workspace<span style="background-color: #ffaaaa; color: red;">\</span>CucumberTestNGSeleniumExecutableJar<span style="background-color: #ffaaaa; color: red;">\</span>target
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">---</span> maven<span style="color: #333333;">-</span>resources<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">plugin:</span><span style="color: #6600ee; font-weight: bold;">2.6</span><span style="color: #333333;">:</span>resources <span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">-</span>resources<span style="color: #333333;">)</span> <span style="background-color: #ffaaaa; color: red;">@</span> CucumberTestNGSeleniumExecutableJar <span style="color: #333333;">---</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Using <span style="background-color: #ffaaaa; color: red;">'</span>UTF<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">8</span><span style="background-color: #ffaaaa; color: red;">'</span> encoding to copy filtered resources<span style="color: #333333;">.</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Copying <span style="color: #0000dd; font-weight: bold;">3</span> resources
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">---</span> maven<span style="color: #333333;">-</span>compiler<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">plugin:</span><span style="color: #6600ee; font-weight: bold;">3.7</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">:</span>compile <span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">-</span>compile<span style="color: #333333;">)</span> <span style="background-color: #ffaaaa; color: red;">@</span> CucumberTestNGSeleniumExecutableJar <span style="color: #333333;">---</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Changes detected <span style="color: #333333;">-</span> recompiling the module<span style="color: #333333;">!</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Compiling <span style="color: #0000dd; font-weight: bold;">5</span> source files to <span style="color: #997700; font-weight: bold;">C:</span><span style="background-color: #ffaaaa; color: red;">\</span>Users<span style="background-color: #ffaaaa; color: red;">\</span>sadakarp<span style="background-color: #ffaaaa; color: red;">\</span>eclipse<span style="color: #333333;">-</span>workspace<span style="background-color: #ffaaaa; color: red;">\</span>CucumberTestNGSeleniumExecutableJar<span style="background-color: #ffaaaa; color: red;">\</span>target<span style="background-color: #ffaaaa; color: red;">\</span>classes
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">---</span> maven<span style="color: #333333;">-</span>resources<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">plugin:</span><span style="color: #6600ee; font-weight: bold;">2.6</span><span style="color: #333333;">:</span>testResources <span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">-</span>testResources<span style="color: #333333;">)</span> <span style="background-color: #ffaaaa; color: red;">@</span> CucumberTestNGSeleniumExecutableJar <span style="color: #333333;">---</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Not copying test resources
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">---</span> maven<span style="color: #333333;">-</span>compiler<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">plugin:</span><span style="color: #6600ee; font-weight: bold;">3.7</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">:</span>testCompile <span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">-</span>testCompile<span style="color: #333333;">)</span> <span style="background-color: #ffaaaa; color: red;">@</span> CucumberTestNGSeleniumExecutableJar <span style="color: #333333;">---</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Not compiling test sources
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">---</span> maven<span style="color: #333333;">-</span>surefire<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">plugin:</span><span style="color: #6600ee; font-weight: bold;">3.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">M7:</span>test <span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">-</span>test<span style="color: #333333;">)</span> <span style="background-color: #ffaaaa; color: red;">@</span> CucumberTestNGSeleniumExecutableJar <span style="color: #333333;">---</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Tests are skipped<span style="color: #333333;">.</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">---</span> maven<span style="color: #333333;">-</span>jar<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">plugin:</span><span style="color: #6600ee; font-weight: bold;">2.4</span><span style="color: #333333;">:</span>jar <span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">-</span>jar<span style="color: #333333;">)</span> <span style="background-color: #ffaaaa; color: red;">@</span> CucumberTestNGSeleniumExecutableJar <span style="color: #333333;">---</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Building <span style="color: #997700; font-weight: bold;">jar:</span> <span style="color: #997700; font-weight: bold;">C:</span><span style="background-color: #ffaaaa; color: red;">\</span>Users<span style="background-color: #ffaaaa; color: red;">\</span>sadakarp<span style="background-color: #ffaaaa; color: red;">\</span>eclipse<span style="color: #333333;">-</span>workspace<span style="background-color: #ffaaaa; color: red;">\</span>CucumberTestNGSeleniumExecutableJar<span style="background-color: #ffaaaa; color: red;">\</span>target<span style="background-color: #ffaaaa; color: red;">\</span>CucumberTestNGSeleniumExecutableJar<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">0.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">-</span>SNAPSHOT<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">---</span> maven<span style="color: #333333;">-</span>assembly<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">plugin:</span><span style="color: #6600ee; font-weight: bold;">3.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">:</span>single <span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">-</span>cli<span style="color: #333333;">)</span> <span style="background-color: #ffaaaa; color: red;">@</span> CucumberTestNGSeleniumExecutableJar <span style="color: #333333;">---</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Building <span style="color: #997700; font-weight: bold;">jar:</span> <span style="color: #997700; font-weight: bold;">C:</span><span style="background-color: #ffaaaa; color: red;">\</span>Users<span style="background-color: #ffaaaa; color: red;">\</span>sadakarp<span style="background-color: #ffaaaa; color: red;">\</span>eclipse<span style="color: #333333;">-</span>workspace<span style="background-color: #ffaaaa; color: red;">\</span>CucumberTestNGSeleniumExecutableJar<span style="background-color: #ffaaaa; color: red;">\</span>target<span style="background-color: #ffaaaa; color: red;">\</span>CucumberTestNGSeleniumExecutableJar<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">0.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">-</span>SNAPSHOT<span style="color: #333333;">-</span>jar<span style="color: #333333;">-</span>with<span style="color: #333333;">-</span>dependencies<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">------------------------------------------------------------------------</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> BUILD SUCCESS
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">------------------------------------------------------------------------</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Total <span style="color: #997700; font-weight: bold;">time:</span> <span style="color: #6600ee; font-weight: bold;">26.979</span> s
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> Finished <span style="color: #997700; font-weight: bold;">at:</span> <span style="color: #0000dd; font-weight: bold;">2022</span><span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">09</span><span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">10</span><span style="color: #997700; font-weight: bold;">T20:</span><span style="color: #0000dd; font-weight: bold;">21</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">45</span><span style="color: #333333;">+</span><span style="color: #0000dd; font-weight: bold;">05</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">30</span>
<span style="color: #333333;">[</span>INFO<span style="color: #333333;">]</span> <span style="color: #333333;">------------------------------------------------------------------------</span>
</pre></div><br /><div><b>maven-assembly-plugin</b> generates two jar files, they are<br /><br /></div><div>1. CucumberTestNGSeleniumExecutableJar-0.0.1-SNAPSHOT.jar</div><div>2. CucumberTestNGSeleniumExecutableJar-0.0.1-SNAPSHOT-jar-with-dependencies.jar</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrN2l_yaOeZX-HX1E-a2fjk-BshVs-_nM-UJwmmAeEgNVOYCoW5_qKVhpk-cIShhbnGi3pIqmzZfoxwhklKmdjHI_9-VYHHYYLGQMhxYvJeb-Df_wz6sEms8RGgpy4JgIbLwrFzgx-jbvi_pExhXQLaKTgRL2hJbjj950zTon-XuMEdc-HWiqiHaZ6Qw/s1247/jars.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="407" data-original-width="1247" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrN2l_yaOeZX-HX1E-a2fjk-BshVs-_nM-UJwmmAeEgNVOYCoW5_qKVhpk-cIShhbnGi3pIqmzZfoxwhklKmdjHI_9-VYHHYYLGQMhxYvJeb-Df_wz6sEms8RGgpy4JgIbLwrFzgx-jbvi_pExhXQLaKTgRL2hJbjj950zTon-XuMEdc-HWiqiHaZ6Qw/w640-h208/jars.png" width="640" /></a></div><br /><div>The jar with the dependencies is called fat jar file and this is the one we call as <b>"executable" or "runnable" jar. <br /></b><br />Make sure that this jar contains the <b>MANIFEST.MF file</b> containing the class that has the main method. Use jar extract tools to view the content inside the jar, I've used "<b>Java Decompiler</b>". <br /><br />The MANIFEST.MF file should contain all the dependencies with <b>Main-Class:</b><b>com<span style="color: #333333;">.</span><span style="color: #0000cc;">sadakar</span><span style="color: #333333;">.</span><span style="color: #0000cc;">common</span><span style="color: #333333;">.</span><span style="color: #0000cc;">BasePage </span></b>as shown in below. </div><div><br /><b>MANIFEST.MF</b></div>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">Manifest<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">Version:</span> <span style="color: #6600ee; font-weight: bold;">1.0</span>
Created<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">By:</span> Apache Maven <span style="color: #6600ee; font-weight: bold;">3.8</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">1</span>
Built<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">By:</span> sadakarp
Build<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">Jdk:</span> <span style="color: #6600ee; font-weight: bold;">16.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">2</span>
Class<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">Path:</span> cucumber<span style="color: #333333;">-</span>java<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">7.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> cucumber<span style="color: #333333;">-</span>core<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">7.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> cucumber<span style="color: #333333;">-</span>ghe
rkin<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">7.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> cucumber<span style="color: #333333;">-</span>gherkin<span style="color: #333333;">-</span>messages<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">7.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> messages<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">17.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span>
tag<span style="color: #333333;">-</span>expressions<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> cucumber<span style="color: #333333;">-</span>expressions<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">13.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> datatable<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">7.1</span>
<span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> cucumber<span style="color: #333333;">-</span>plugin<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">7.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> docstring<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">7.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> html<span style="color: #333333;">-</span>formatter<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">17</span><span style="color: #333333;">.</span>
<span style="color: #6600ee; font-weight: bold;">0.0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> create<span style="color: #333333;">-</span>meta<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">6.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> apiguardian<span style="color: #333333;">-</span>api<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> cucumber<span style="color: #333333;">-</span>testng
<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">7.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>java<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>api<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>chro
me<span style="color: #333333;">-</span>driver<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> auto<span style="color: #333333;">-</span>service<span style="color: #333333;">-</span>annotations<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> auto<span style="color: #333333;">-</span>service<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.0</span>
<span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> auto<span style="color: #333333;">-</span>common<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.2</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> guava<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">31.1</span><span style="color: #333333;">-</span>jre<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> failureaccess<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> l
istenablefuture<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">9999.0</span><span style="color: #333333;">-</span>empty<span style="color: #333333;">-</span>to<span style="color: #333333;">-</span>avoid<span style="color: #333333;">-</span>conflict<span style="color: #333333;">-</span>with<span style="color: #333333;">-</span>guava<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> jsr305<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">.</span>
<span style="color: #6600ee; font-weight: bold;">0.2</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> checker<span style="color: #333333;">-</span>qual<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">3.12</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> error_prone_annotations<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">2.11</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> j2ob
jc<span style="color: #333333;">-</span>annotations<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.3</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>chromium<span style="color: #333333;">-</span>driver<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>json
<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>devtools<span style="color: #333333;">-</span>v101<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>devtools<span style="color: #333333;">-</span>v102<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span>
<span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>devtools<span style="color: #333333;">-</span>v103<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>devtools<span style="color: #333333;">-</span>v85<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span>
selenium<span style="color: #333333;">-</span>edge<span style="color: #333333;">-</span>driver<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>firefox<span style="color: #333333;">-</span>driver<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> seleni
um<span style="color: #333333;">-</span>ie<span style="color: #333333;">-</span>driver<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>opera<span style="color: #333333;">-</span>driver<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>remote<span style="color: #333333;">-</span>
driver<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>buffer<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>codec<span style="color: #333333;">-</span>http<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span>
Final<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>codec<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>handler<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> n
etty<span style="color: #333333;">-</span>common<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>transport<span style="color: #333333;">-</span>classes<span style="color: #333333;">-</span>epoll<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span>
<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>transport<span style="color: #333333;">-</span>classes<span style="color: #333333;">-</span>kqueue<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>transport<span style="color: #333333;">-</span>na
tive<span style="color: #333333;">-</span>epoll<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>transport<span style="color: #333333;">-</span><span style="color: #008800; font-weight: bold;">native</span><span style="color: #333333;">-</span>kqueue<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span>
jar netty<span style="color: #333333;">-</span>transport<span style="color: #333333;">-</span><span style="color: #008800; font-weight: bold;">native</span><span style="color: #333333;">-</span>unix<span style="color: #333333;">-</span>common<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>transport
<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>resolver<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">78</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentelemetry<span style="color: #333333;">-</span>api<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.1</span>
<span style="color: #6600ee; font-weight: bold;">5.0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentelemetry<span style="color: #333333;">-</span>context<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.15</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentelemetry<span style="color: #333333;">-</span>exporter<span style="color: #333333;">-</span>logging
<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.15</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentelemetry<span style="color: #333333;">-</span>sdk<span style="color: #333333;">-</span>metrics<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.15</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentelemetry<span style="color: #333333;">-</span>sdk<span style="color: #333333;">-</span>logs
<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.15</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">-</span>alpha<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentelemetry<span style="color: #333333;">-</span>sdk<span style="color: #333333;">-</span>common<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.15</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentelemetry<span style="color: #333333;">-</span>sdk
<span style="color: #333333;">-</span>extension<span style="color: #333333;">-</span>autoconfigure<span style="color: #333333;">-</span>spi<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.15</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentelemetry<span style="color: #333333;">-</span>sdk<span style="color: #333333;">-</span>extension<span style="color: #333333;">-</span>aut
oconfigure<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.15</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">-</span>alpha<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentelemetry<span style="color: #333333;">-</span>sdk<span style="color: #333333;">-</span>trace<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.15</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentele
metry<span style="color: #333333;">-</span>sdk<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.15</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> opentelemetry<span style="color: #333333;">-</span>semconv<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.15</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">-</span>alpha<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> jtoml<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">2.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> <span style="color: #333399; font-weight: bold;">byte</span><span style="color: #333333;">-</span>buddy<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.12</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">10</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> commons<span style="color: #333333;">-</span>exec<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.3</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> async<span style="color: #333333;">-</span>http<span style="color: #333333;">-</span>client<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">2.12</span>
<span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> async<span style="color: #333333;">-</span>http<span style="color: #333333;">-</span>client<span style="color: #333333;">-</span>netty<span style="color: #333333;">-</span>utils<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">2.12</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>codec<span style="color: #333333;">-</span>socks<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">6</span>
<span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>handler<span style="color: #333333;">-</span>proxy<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>transport<span style="color: #333333;">-</span><span style="color: #008800; font-weight: bold;">native</span>
<span style="color: #333333;">-</span>epoll<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">-</span>linux<span style="color: #333333;">-</span>x86_64<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>transport<span style="color: #333333;">-</span><span style="color: #008800; font-weight: bold;">native</span><span style="color: #333333;">-</span>kqueue<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span>
<span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Final</span><span style="color: #333333;">-</span>osx<span style="color: #333333;">-</span>x86_64<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> reactive<span style="color: #333333;">-</span>streams<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> netty<span style="color: #333333;">-</span>reactive<span style="color: #333333;">-</span>strea
ms<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">2.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> slf4j<span style="color: #333333;">-</span>api<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.7</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">30</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> jakarta<span style="color: #333333;">.</span><span style="color: #0000cc;">activation</span><span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.2</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium
<span style="color: #333333;">-</span>http<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> failsafe<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">3.2</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> selenium<span style="color: #333333;">-</span>safari<span style="color: #333333;">-</span>driver<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> sel
enium<span style="color: #333333;">-</span>support<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> testng<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">7.1</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> jcommander<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.72</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> guice<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">4.1</span><span style="color: #333333;">.</span>
<span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">-</span>no_aop<span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> javax<span style="color: #333333;">.</span><span style="color: #0000cc;">inject</span><span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> aopalliance<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.0</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span> snakeyaml<span style="color: #333333;">-</span><span style="color: #6600ee; font-weight: bold;">1.21</span><span style="color: #333333;">.</span><span style="color: #0000cc;">jar</span>
<span style="color: #333333;">.</span>
Main<span style="color: #333333;">-</span><span style="color: #997700; font-weight: bold;">Class:</span> <b>com<span style="color: #333333;">.</span><span style="color: #0000cc;">sadakar</span><span style="color: #333333;">.</span><span style="color: #0000cc;">common</span><span style="color: #333333;">.</span><span style="color: #0000cc;">BasePage</span></b>
</pre></div><br />Now, let's run the jar file: <br />Double click on the executable jar, it will start executing the scenarios! <br /><br />Or use below command to run the cucumber scenarios<br /><br /><span style="color: red;">Command is updated on 18 June 2023</span><br /><div><span style="background-color: #eeeeee;"><b>java -jar </b><b>-Dcucumber.filter.tags="@HRMLogin" </b><b><i>CucumberTestNGSeleniumExecutableJar-0.0.1-SNAPSHOT-jar-with-dependencies.jar</i> </b></span></div><div><br /><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_AymlElfPQhupZ1MqNLTyJwRkjJIb-LFC5xcbF2msUfpfDRf18tgu-gDvVRoXEyxvoTIkKnP9B8zrS5QgUIKwgMfYXL65yRWcZh1teovYFb18Tf7e8STLnHHQiWn64rQKgxDXcHleBztu8kXUOJoicPVrkPTFRXafQtbVZcJ1XsuQZoMRmSUz1w6vZw/s1850/run2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="762" data-original-width="1850" height="264" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_AymlElfPQhupZ1MqNLTyJwRkjJIb-LFC5xcbF2msUfpfDRf18tgu-gDvVRoXEyxvoTIkKnP9B8zrS5QgUIKwgMfYXL65yRWcZh1teovYFb18Tf7e8STLnHHQiWn64rQKgxDXcHleBztu8kXUOJoicPVrkPTFRXafQtbVZcJ1XsuQZoMRmSUz1w6vZw/w640-h264/run2.png" width="640" /></a></div><br />This execution, will generate, cucumber reports in "<b>target</b>" folder where the jar is located. <br /><br />The report is based on the plug-in(s) that we provide in <b>BasePage.java</b> file. <br />For example, we gave it as <div><br /><div><b>"-p", "json:target/cucumber-reports/cucumber.json", </b></div><div><b>"-p", "html:target/cucumber-reports/cucumberreport.html",</b><br /><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwSyVxyupknrhKZmMXswhA-HhLHqDYqtQj96pewJXiFC1MfYjOpy7fKswg7s67Apuif4UynT4d5bGRW22I22JPDUJg_JqVNGUPEL25YfuGXOTZ8Rb4rrHf31sqq5Maq8D-cXdz58RR60DV88yAy0BGSjc2BgCvp431LjQ2Qyd09WHbAxHRXtcn4EvhRw/s728/run3.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="456" data-original-width="728" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwSyVxyupknrhKZmMXswhA-HhLHqDYqtQj96pewJXiFC1MfYjOpy7fKswg7s67Apuif4UynT4d5bGRW22I22JPDUJg_JqVNGUPEL25YfuGXOTZ8Rb4rrHf31sqq5Maq8D-cXdz58RR60DV88yAy0BGSjc2BgCvp431LjQ2Qyd09WHbAxHRXtcn4EvhRw/w640-h400/run3.png" width="640" /></a></div><br />click on the "<b>cucumberreport.html</b>" file to analyze the report generated. <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI6Dz3ckjKJWaQ4vH5mFQSuYastZpsk27CggPbhvz4k9GrtYR-OeHv1uad_3BtIhZUXeNPDYkjJV5-MRPZ7YHMw2CHr_tLL1q9ElGwlqpbcXQFmEGaW3o-d2Pa-RzCb4VBwlD4CmT7O372cKjLlXQOoPYauwfw2GfVjdhbl1M1Ov5bQ2ymnsde13amBg/s1271/run4.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="701" data-original-width="1271" height="352" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI6Dz3ckjKJWaQ4vH5mFQSuYastZpsk27CggPbhvz4k9GrtYR-OeHv1uad_3BtIhZUXeNPDYkjJV5-MRPZ7YHMw2CHr_tLL1q9ElGwlqpbcXQFmEGaW3o-d2Pa-RzCb4VBwlD4CmT7O372cKjLlXQOoPYauwfw2GfVjdhbl1M1Ov5bQ2ymnsde13amBg/w640-h352/run4.png" width="640" /></a></div><br />That's all we have to do to create an executable cucumber, testng jar file using maven and to run the scenarios from it. <br /><br />I hope you found this write-up useful, keep watch this blog site for more automation! </div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-13448559348554038792022-08-23T13:34:00.013+05:302022-09-08T00:10:17.492+05:30What are Waits in selenium ? Implicit, Explicit and Fluent waits in Selenium<div style="text-align: left;"><div style="text-align: left;"><h3 style="text-align: left;"><b><span style="color: #073763;">What are Waits in selenium ?</span></b></h3><div><span style="white-space: pre;"> </span>1) Implicit wait </div><div><span style="white-space: pre;"> </span>2) Explicit wait</div><div><br /></div><div>1) Implicit wait</div><div><span style="white-space: pre;"> </span>a) implicitlyWait()</div><div><span style="white-space: pre;"> </span>b) pageLoadTimeout()</div><div><span style="white-space: pre;"> </span>c) setScriptTimeout()<br /><br /></div><div>2) Explicit wait </div><div><span style="white-space: pre;"> </span>a) WebDriverWait</div><div><span style="white-space: pre;"> </span>b) Fluent</div><div><br /></div><h3 style="text-align: left;"><span style="color: #073763;">Implicit wait | implicitlyWait()</span></h3><div><ul style="text-align: left;"><li>implicitlyWait is applied to all the web elements on the web page.</li><li>It will throw "No Such Element Exception" after reaching the time. </li><li>Implicit wait stays in place for the entire duration for which the browser is open.</li><li>The default value of implicit wait is 0.</li><li>Implicit wait is applied for the lifetime of the Webdriver, it can extend the test execution times to a large value depending on the number of elements on which it is being called.</li><li><b> When to use implicitlyWait? </b></li><li> It is recommended to use implicit wait only when you are in complete control of the script.</li><li><b>Example: </b></li></ul></div><div><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"> <span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">this</span> <span style="color: #0e84b5; font-weight: bold;">package</span> : <span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.time.Duration</span>;
</pre><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"> <b> driver.<span style="color: #0000cc;">manage</span>().<span style="color: #0000cc;">timeouts</span>().<span style="color: #0000cc;">implicitlyWait</span>(Duration.<span style="color: #0000cc;">ofSeconds</span>(<span style="color: #0000dd;">60</span>))</b></pre></div><div><br /></div><h3 style="text-align: left;"><span style="color: #073763;">Implicit wait | pageLoadTimeout()</span></h3><div><ul style="text-align: left;"><li>It waits for the page to load completely for the specified number of seconds. </li><li>Default value is : 0 </li><li><b>Example</b>:<br /><b><br /></b><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"><b>WebDriver driver = <span style="color: #008800;">new</span> ChromeDriver();
driver.<span style="color: #0000cc;">manage</span>().<span style="color: #0000cc;">timeouts</span>().<span style="color: #0000cc;">pageLoadTimeout</span>(<span style="color: #0000dd;">30</span>, TimeUnit.<span style="color: #0000cc;">SECONDS</span>);
driver.<span style="color: #0000cc;">get</span>(<span style="background-color: #fff0f0;">"https://demoqa.com/login"</span>);</b></pre></li></ul><ul style="text-align: left;"><li>WebDriver will wait for a maximum of 30 seconds before moving ahead with the interaction with the element.</li></ul></div><div><br /></div><h3 style="text-align: left;"><span style="color: #073763;">Implicit wait | setScriptTimeout()</span></h3><div><ul style="text-align: left;"><li>The setScriptTimeout command waits for the asynchronous parts of the web page to finish loading for a specified number of seconds.</li><li><b>Example:</b><br /><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"><b>driver.<span style="color: #0000cc;">manage</span>().<span style="color: #0000cc;">timeouts</span>().<span style="color: #0000cc;">setScriptTimeout</span>(<span style="color: #0000dd;">15</span>, TimeUnit.<span style="color: #0000cc;">SECONDS</span>);
((JavascriptExecutor) driver).<span style="color: #0000cc;">executeScript</span>(<span style="background-color: #fff0f0;">"alert('hello world');"</span>);
((JavascriptExecutor) driver).<span style="color: #0000cc;">executeAsyncScript</span>(<span style="background-color: #fff0f0;">"window.setTimeout(arguments[arguments.length - 1], 500);"</span>);</b></pre></li></ul></div><div><ul style="text-align: left;"><li>WebDriver will wait for a maximum of 15 seconds before moving ahead with the interaction with the element.</li></ul></div><div><br /></div><h3 style="text-align: left;"><span style="color: #073763;">Explicit wait | WebDriverWait</span></h3><div><ul style="text-align: left;"><li>It is a conditional wait strategy </li><li>Wait until the the condition specified becomes true or the time duration is elapsed. </li><li>Explicit wait is only applied on the specified element. </li><li>Commonly used conditions are : </li></ul></div><div><span style="white-space: pre;"> <span> </span></span><b><span style="color: #333333;">presenceOfElementLocated</span><span style="color: #333333;">()</span></b></div><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"><b><span> <span> </span></span>elementToBeClickable()
<span> <span> </span></span>visibilityOfElementLocated()</b></pre><div><ul style="text-align: left;"><li><b>WebDriverWait </b>class and <b>ExpectedConditions </b>specifies the time and condition for which the WebDriver needs to wait.<br /><br /></li><li><b>Example-1 : </b></li></ul></div><div><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"><b><span> </span>WebDriverWait wait = <span style="color: #008800;">new</span> WebDriverWait(driver,Duration.<span style="color: #0000cc;">ofSeconds</span>(<span style="color: #0000dd;">30</span>));
<span> </span>wait.<span style="color: #0000cc;">until</span>(ExpectedConditions.<span style="color: #0000cc;">visibilityOfElementLocated</span>(By.<span style="color: #0000cc;">xpath</span>(<span style="background-color: #fff0f0;">"//input[@id='searchBox']"</span>)));</b></pre></div><div><ul style="text-align: left;"><li><b>Example-2: <br /><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;">WebElement searchBox = <span style="color: #008800;">new</span> WebDriverWait(driver, Duration.<span style="color: #0000cc;">ofSeconds</span>(<span style="color: #0000dd;">10</span>))
.<span style="color: #0000cc;">until</span>(ExpectedConditions.<span style="color: #0000cc;">presenceOfElementLocated</span>(By.<span style="color: #0000cc;">xpath</span>(<span style="background-color: #fff0f0;">"//input[@id='searchBox']"</span>)));</pre></b></li></ul></div><div><ul style="text-align: left;"><li><b>Example-3: <br /><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;">WebElement searchBox = <span style="color: #008800;">new</span> WebDriverWait(driver, Duration.<span style="color: #0000cc;">ofSeconds</span>(<span style="color: #0000dd;">30</span>))
.<span style="color: #0000cc;">until</span>(driver -> driver.<span style="color: #0000cc;">findElement</span>(By.<span style="color: #0000cc;">name</span>(<span style="background-color: #fff0f0;">"//input[@id='searchBox']"</span>)));</pre></b></li></ul></div><div><span style="white-space: pre;"> </span></div><h3 style="text-align: left;"><span style="color: #073763;">Explicit </span><span style="color: #073763;">wait</span><span style="color: #073763;">| Fluent wait</span></h3><div><ul style="text-align: left;"><li>Fluent wait is similar to Explicity wait </li><li>It takes an additional argument frequency i.e., polling time. </li><li>frequency number tells the WebDriver to keep on checking for the element at regular time intervals wait till the maximum of "Duration.ofSeconds"</li><li>If the element becomes avaialble earlier, we proceed with the test execution and finish quickly. </li><li><b>Example: </b><br /><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"><b>Wait<WebDriver> wait = <span style="color: #008800;">new</span> FluentWait<WebDriver>(driver)
.<span style="color: #0000cc;">withTimeout</span>(Duration.<span style="color: #0000cc;">ofSeconds</span>(<span style="color: #0000dd;">30</span>))
.<span style="color: #0000cc;">pollingEvery</span>(Duration.<span style="color: #0000cc;">ofSeconds</span>(<span style="color: #0000dd;">5</span>))
.<span style="color: #0000cc;">ignoring</span>(NoSuchElementException.<span style="color: #0000cc;">class</span>);
</b></pre></li><ul><li>Maximum waiting time is 30 seconds </li><li>polling time is 5 seconds </li><li>WebDriver keeps on checking for the element for every 5 seconds to a maximum of 30 seconds ignoring will ignore the exception NoSuchElementException while the driver finds the element in the maximum time.<br /><br /></li></ul><li><b>When to use ? <br /></b>When dealing with AJAX elements </li></ul></div><h3 style="text-align: left;"><br /><span style="color: #073763;">Which is best wait ? When to use which wait ? </span></h3><div><b>Explicit wait : </b></div><div><ul style="text-align: left;"><li>Saves the time and is not applicable for all elements.</li><li>Wait only based on condition and time for a specified element. </li></ul></div><div><br /></div><div><b>Implicit wait : </b></div><div><ul style="text-align: left;"><li>It is applied once for all the elements and the next wait cycle starts once the previous one completes. </li><li>Implicitly waits needs a better understanding of scripts.</li></ul></div><div><b><i><span style="color: red;">There is no best type of wait, based on the demand of the element find strategy we use any of the waits above. </span></i></b></div><div><br /></div><div><br /></div><div><b>NOTE:</b></div><div> Do not mix implicit and explicit waits! Doing so can cause unpredictable wait times. </div><div> For example, setting an implicit wait of 20 seconds and an explicit wait of 35 seconds could cause a timeout to occur after 25 seconds.</div><div><br /></div><div><br /></div><div><b><span style="color: #073763;">What is polling time ? </span></b></div><div>The polling time (or polling interval) is the time interval in which Selenium starts searching again after the last failed try. </div><div><ul style="text-align: left;"><li>It depends on the type of browser driver you are working on. </li><li>Some may have 500 milliseconds while some may have 1 second as polling time. </li><li>The polling time is inbuild in implicitlyWait and there is no way to modify the time interval. </li></ul></div><div><ul style="text-align: left;"><li>The default pooling period for implicit and explicit wait is 250 ms.</li><li> During implicitlyWait, the WebDriver will poll the DOM for certain specified time units while trying to find any element. </li><li> If the element is found earlier, the test executes at that point otherwise the WebDriver waits for the specified duration.</li></ul></div><div><br /></div><div><b><span style="color: #073763;">Thread.sleep()</span></b></div><div><ul style="text-align: left;"><li>Thread.sleep() pauses the execution</li><li>Sleep is a static method that belongs to the ‘Thread’ class of Java.</li><li>Thread.sleep() sets the condition to an exact time period to wait.</li></ul></div><div><b><span style="color: #073763;">What is the difference between sleep and selenium waits ? </span></b></div><div><ul style="text-align: left;"><li>Thread.sleep() will stop the execution of the script for the time specified in the script, irrespective of the fact that the element on the web page has been found.</li><li>Selenium waits do not wait for the complete duration of time. If the WebDriver is able to find the element before the specified time duration, it moves on to the next line of code. </li><li>This helps in reducing the overall time of script execution by a considerable margin.</li></ul></div><div><b><span style="color: #073763;">Selenium setSpeed()</span></b></div><div>setSpeed() sets the desired speed of execution or delays execution by a specified amount of time before each operation.</div><div><br /></div></div></div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-28752965617071404102022-08-17T15:52:00.020+05:302022-08-18T08:22:47.168+05:30How to configure postman/newman API tests in Azure DevOps for Continuous Integration (CI) process<div style="text-align: left;"><div><div><span style="font-size: medium;"><b>How to configure postman/newman API tests in Azure DevOps</b> </span></div><ol style="text-align: left;"><li><span style="font-size: medium;">Export the postman collection and environment </span></li><li><span style="font-size: medium;">Push the collection/environment to "Azure Repos Git" repository</span></li><li><span style="font-size: medium;">Navigate to Pipeline page in Azure DevOps and click on "New pipeline" button on the top right corner. </span></li><li><span style="font-size: medium;">Click on "Use the classic editor" link in the bottom to create a pipeline without YAML.</span></li><li><span style="font-size: medium;">Select the source for the postman tests</span></li><li><span style="font-size: medium;">Select a template > Click on "Empty job"</span></li><li><span style="font-size: medium;">A new pipe line is created with default name </span></li><li><span style="font-size: medium;"> Add the tasks</span></li><ul><li><span style="font-size: medium;">Install newman </span></li><li><span style="font-size: medium;">Newman command to run the tests</span></li><li><span style="font-size: medium;">Publish Test results</span></li></ul><li><span style="font-size: medium;"> Save the pipe line and Queue(run the pipeline) </span></li><li><span style="font-size: medium;"> Analysis of Junit Report</span></li><li><span style="font-size: medium;">Analysis of published report</span></li></ol></div><div><span style="font-size: medium;"><br /></span></div><div><span style="font-size: medium;">Let's look into each of the steps above in detail. </span></div><div><h3 style="text-align: left;"><span style="color: #073763; font-size: medium;">Export the postman collection and environment as .json files </span></h3><div><ul style="text-align: left;"><li><span style="font-size: medium;">Create a Collection, create a GET request, write tests for the request</span></li><li><span style="font-size: medium;">Here is a sample request created : <a href="https://learning.postman.com/docs/getting-started/sending-the-first-request/">https://learning.postman.com/docs/getting-started/sending-the-first-request/</a></span></li><li><span style="font-size: medium;">Tests written for the above GET request are as follows</span></li><li><span style="font-size: medium;"><span><b>NOTE:</b> For the demonstration purposes, I've not taken environment for this example. <br /></span><!--HTML generated using hilite.me--></span><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="font-size: medium;">pm.test(<span style="background-color: #fff0f0;">"Status code is 200 OK"</span>, <span style="color: #008800; font-weight: bold;">function</span> () {
pm.response.to.have.status(<span style="color: #0000dd; font-weight: bold;">200</span>);
});
pm.test(<span style="background-color: #fff0f0;">"Response time is less than 10s"</span>, <span style="color: #008800; font-weight: bold;">function</span> () {
pm.expect(pm.response.responseTime).to.be.below(<span style="color: #0000dd; font-weight: bold;">10000</span>);
});
pm.test(<span style="background-color: #fff0f0;">"Body contains url"</span>,() <span style="color: #333333;">=></span> {
pm.expect(pm.response.text()).to.include(<span style="background-color: #fff0f0;">"http://postman-echo.com/get"</span>);
});</span></pre></div></li></ul><ul style="text-align: left;"><li><span style="color: #073763; font-size: medium;">Collection Name : <b>00Test.postman_collection.json</b></span></li></ul></div><h3 style="text-align: left;"><span style="font-size: medium;"><span style="color: #073763;">Push the collection/environment to "Azure Repos Git" repository</span><br /></span><div style="text-align: left;"><ul style="text-align: left;"><li><span style="font-size: medium; font-weight: normal;">Use git commit and push the code to Azure Git repository</span></li><li><span style="font-size: medium;"><span style="font-weight: normal;">Click on the image below to get the best view. </span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh55G-2WCu0kgDnPLIXwnvrVFrYqSJQ7T7QWdnJcelzTEa-Zm6X2q3NTS9m053-PKO-cwn0zZb8Y7qqXmM3sTlqYRoRlXQoT8YMvRp1oPV0651piipQcOz6_Kt7cRFHP1Xlo4j5Qdo1obN_84-WqntsX3hhq24inB-OaZQXLXodNjeIiLa1Zz_oz_EqpA/s1550/api%20automation.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="919" data-original-width="1550" height="379" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh55G-2WCu0kgDnPLIXwnvrVFrYqSJQ7T7QWdnJcelzTEa-Zm6X2q3NTS9m053-PKO-cwn0zZb8Y7qqXmM3sTlqYRoRlXQoT8YMvRp1oPV0651piipQcOz6_Kt7cRFHP1Xlo4j5Qdo1obN_84-WqntsX3hhq24inB-OaZQXLXodNjeIiLa1Zz_oz_EqpA/w640-h379/api%20automation.png" width="640" /></a></span></li></ul></div></h3><h3 style="text-align: left;"><span style="color: #073763; font-size: medium;">Navigate to Pipeline page in Azure DevOps and click on "New pipeline" button on the top right corner. </span></h3><h3 style="text-align: left;"><span style="font-size: medium;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie5oR9nW7gpc6wpkRyXWbWjWKxBhZdNbjP2hJpnIvs0Jbt7IeN-oW4AVtlVC2j38ORLLf4Rh0nGIO26YhGqHpthVGioKVL_fujWEyiPtZZxUw8MjP5HfPEiWrBUDrsxV7RuJUeO01-Z2znqr9MdNcQ6DrohOMsl40Y-dUbn-00xG9b31kskKwUDBta4g/s427/pipeline.png" style="font-weight: 400; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="427" data-original-width="327" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie5oR9nW7gpc6wpkRyXWbWjWKxBhZdNbjP2hJpnIvs0Jbt7IeN-oW4AVtlVC2j38ORLLf4Rh0nGIO26YhGqHpthVGioKVL_fujWEyiPtZZxUw8MjP5HfPEiWrBUDrsxV7RuJUeO01-Z2znqr9MdNcQ6DrohOMsl40Y-dUbn-00xG9b31kskKwUDBta4g/w306-h400/pipeline.png" width="306" /></a></span></h3><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBUeZdqQaqL_m8Bxa2Uu7d_CPGMHRjtOVR8xk-GHd_kl5-g-Cwpq2CYlY332m4aVdPLMrYq2YnTSyokPbj4p9bvtZavwhBKbD-xHSVzasUb-QcFaciO5YXbE-VlQD2ne_G2f6jJoLM1-T7V49UYkmiqn2Q97W6Fhyxx0bc_7p79xnoYR4XMltLxIprQQ/s1556/p1.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: medium;"><img border="0" data-original-height="282" data-original-width="1556" height="116" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBUeZdqQaqL_m8Bxa2Uu7d_CPGMHRjtOVR8xk-GHd_kl5-g-Cwpq2CYlY332m4aVdPLMrYq2YnTSyokPbj4p9bvtZavwhBKbD-xHSVzasUb-QcFaciO5YXbE-VlQD2ne_G2f6jJoLM1-T7V49UYkmiqn2Q97W6Fhyxx0bc_7p79xnoYR4XMltLxIprQQ/w640-h116/p1.png" width="640" /></span></a></div><h3 style="text-align: left;"><span style="font-size: medium;"><br /><span style="color: #073763;">Click on "Use the classic editor" link in the bottom to create a pipeline without YAML.</span></span></h3><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4VCXj7xkTW4NLMV0Yx6nd6tXsYx7xDnDMcFdrY8CG6LN9QIGv10eNmED74zUEY8hTWjmC-iuE4XcYUfZhXzRNneg1dFawtUzlk874ddP9Q3vGpGEq5Ums01of_moGnhJmL-MOewD1-ypAuZ6it_CzHtuFacbXOnllGh6uFKySQBlRBOXBm2Sz_0hGVQ/s865/p2.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: medium;"><img border="0" data-original-height="716" data-original-width="865" height="530" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4VCXj7xkTW4NLMV0Yx6nd6tXsYx7xDnDMcFdrY8CG6LN9QIGv10eNmED74zUEY8hTWjmC-iuE4XcYUfZhXzRNneg1dFawtUzlk874ddP9Q3vGpGEq5Ums01of_moGnhJmL-MOewD1-ypAuZ6it_CzHtuFacbXOnllGh6uFKySQBlRBOXBm2Sz_0hGVQ/w640-h530/p2.png" width="640" /></span></a></div><h3 style="text-align: left;"><span style="color: #073763; font-size: medium;">Select the source for postman tests</span></h3><div style="text-align: left;"><ul style="text-align: left;"><li><span style="font-size: medium;">Select the "Team Project", "Repository", "Branch" and click on Continue button </span></li></ul></div><h3 style="text-align: left;"><span style="font-size: medium;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKflIOFaJB54hoYuHk2p_x943q9MAFO__AigCDQVGEIapkQl_wZ6EDsotrULy2OQklx2AIAlYQoJJULtgSfqcwiyol0tB6guNOVMsLqr20t6YtzyG5Fu2J74ott3ZZ9DqBGqnjGYLtZwTwo64CiK3MGBQouGRxhk4H2KAh85zQrk2bjtX8kEyBf-Ke4w/s1552/p3.png" style="font-weight: 400; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="775" data-original-width="1552" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKflIOFaJB54hoYuHk2p_x943q9MAFO__AigCDQVGEIapkQl_wZ6EDsotrULy2OQklx2AIAlYQoJJULtgSfqcwiyol0tB6guNOVMsLqr20t6YtzyG5Fu2J74ott3ZZ9DqBGqnjGYLtZwTwo64CiK3MGBQouGRxhk4H2KAh85zQrk2bjtX8kEyBf-Ke4w/w640-h320/p3.png" width="640" /></a><br /><br /><span style="color: #073763;">Select a template > Click on "Empty job"</span><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVxbtBMjAwckJ32cbpQrXUMhKTH1mYqvhruATXFbOeI6QMCMPFdcDdtgdo47eMTILrMpHurXPdCJBYA06EPR4RByKMTM1cvO1it7dQGDnBP3Td7zf5spVYNKfFtwu1UUIAIe3eFkVzvZeneNNq1A0SuHhcdJF4W8mfWamf5latOb0mQGRvwRKyadC5Xw/s1540/p5.png" style="font-weight: 400; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="855" data-original-width="1540" height="356" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVxbtBMjAwckJ32cbpQrXUMhKTH1mYqvhruATXFbOeI6QMCMPFdcDdtgdo47eMTILrMpHurXPdCJBYA06EPR4RByKMTM1cvO1it7dQGDnBP3Td7zf5spVYNKfFtwu1UUIAIe3eFkVzvZeneNNq1A0SuHhcdJF4W8mfWamf5latOb0mQGRvwRKyadC5Xw/w640-h356/p5.png" width="640" /></a><br /><br /></span></h3><h3 style="text-align: left;"><span style="color: #073763; font-size: medium;">A new pipe line is created with default name <br /></span><div style="text-align: left;"><span style="font-weight: normal;"><span style="font-size: medium;">Set the below basic properties and the remaining are optional and can be configured on demand basis. <br /><br />Display name : Agent job1<br />Agent pool : <inherit from pipeline><br /><br /></span></span></div><span style="font-size: medium;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVx2IRanSySFvsaCOdN8kx3djLulrShJEAmENh2zcTY_zFF0ifZLgQCW5NUxIfBmntSwCrqMKtP5diGfcdfDzRCG23fRrJwR-CRpNa5HXkzPlyc6Q_UMsEWIiVUYmeYnrQL0_FnZ_016VvuXxCQjotR56GEvMa4kSCuYdsAevgoppRywPBsBSXpp3dZw/s1582/p6.png" style="font-weight: 400; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="838" data-original-width="1582" height="339" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVx2IRanSySFvsaCOdN8kx3djLulrShJEAmENh2zcTY_zFF0ifZLgQCW5NUxIfBmntSwCrqMKtP5diGfcdfDzRCG23fRrJwR-CRpNa5HXkzPlyc6Q_UMsEWIiVUYmeYnrQL0_FnZ_016VvuXxCQjotR56GEvMa4kSCuYdsAevgoppRywPBsBSXpp3dZw/w640-h339/p6.png" width="640" /></a><br /> </span></h3><h3 style="text-align: left;"><span style="color: #073763; font-size: medium;">Add the tasks<br /></span><div style="text-align: left;"><span><span style="font-size: medium; font-weight: normal;">To add the tasks click on + button on the Agent job. <br />I am taking 3 tasks for the tests to run, they are as follows. </span></span></div><ol style="text-align: left;"><li><span style="color: #073763; font-size: medium;">Install newman </span></li><li><span style="color: #073763; font-size: medium;">Newman command to run the tests </span></li><li><span style="color: #073763; font-size: medium;">Publish Test results</span></li></ol></h3><div style="text-align: left;"><span style="color: #134f5c; font-size: medium;"><u><b>Install newman<br /><br /></b></u></span></div><div style="text-align: left;"><span><span style="font-size: medium; font-weight: normal;">Search for the command line plugin at the top right corner and then Add the command line task. </span></span></div><div style="text-align: left;"><span style="font-size: medium;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfLupzaOF_pqbNhyfii1c7brRVrY0S29q6SjBwt9xY4rwALOjPe9WfJELp0gF3_aECBSgWuCy5UPHiIQZv2hTlJulBJvjD8QtzF9SNhn4Hy25HVsq3-JaGIRuOJ3JLMDaA0K_8wjc6aD7GDPpjhcZBsJPVUsUONkBRtIJuYjHRsMu3gl8_X_rxH-wZJg/s1533/p7.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="570" data-original-width="1533" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfLupzaOF_pqbNhyfii1c7brRVrY0S29q6SjBwt9xY4rwALOjPe9WfJELp0gF3_aECBSgWuCy5UPHiIQZv2hTlJulBJvjD8QtzF9SNhn4Hy25HVsq3-JaGIRuOJ3JLMDaA0K_8wjc6aD7GDPpjhcZBsJPVUsUONkBRtIJuYjHRsMu3gl8_X_rxH-wZJg/w640-h238/p7.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><span style="font-weight: normal;">Fill the required properties for the task added, for instance, we install postman command line tool that is newman using npm package. <br /></span><br />Display name : Install newman<br /><div class="separator" style="clear: both;">Script : <b>npm install -g newman </b><br /><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxoYax4T2VGVN4l36eoR_YKlgO2oZnUt7GlMN0TbJInOlWFsFNyL-tUVDdElmS9yydK0r9gHgRTvIGPjITF-1rK8of_2VTSkuH43hk6r3JTfI7gP3t1oy2sqrZQq_MTz_DFA_owRUBjIMtSuaCCc7hJ6Pp87I5YxjNg8IF1a6HyCMJlvBjsk_39nMPmg/s1532/s1.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="583" data-original-width="1532" height="244" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxoYax4T2VGVN4l36eoR_YKlgO2oZnUt7GlMN0TbJInOlWFsFNyL-tUVDdElmS9yydK0r9gHgRTvIGPjITF-1rK8of_2VTSkuH43hk6r3JTfI7gP3t1oy2sqrZQq_MTz_DFA_owRUBjIMtSuaCCc7hJ6Pp87I5YxjNg8IF1a6HyCMJlvBjsk_39nMPmg/w640-h244/s1.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: left;"><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;"><br /></pre><pre style="color: #333333; line-height: 16.25px; margin-bottom: 0px; margin-top: 0px;">The corresponding YAML script to install the newman is
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; text-align: left; width: auto;"><pre style="line-height: 125%; margin: 0px;">steps:
- script: |
<span style="color: #003366; font-weight: bold;">npm install -g newman </span>
displayName: <span style="background-color: #fff0f0;">'Install</span><span style="color: #996633;"> </span><span style="background-color: #fff0f0;">newman'</span>
</pre></div></pre></div></div></span></div><div style="text-align: left;"><span style="color: #134f5c; font-size: medium;"><u><b><br />Newman command to run the tests</b></u></span></div><div style="text-align: left;"><span><span style="font-size: medium; font-weight: normal;">Add one more command line plug-in to run the postman API tests (This we can do in the previous step itself, I wanted to separate out the installation task to the test execution task so the second command line plugin). <br /><br />Use below script command to run the collection<br /><br /></span></span></div><div style="text-align: left;"><span><span style="font-size: medium; font-weight: normal;">Display name : Newman command to run tests</span></span></div><div style="text-align: left;"><span style="font-size: medium;"><span><span style="font-weight: normal;">Script: </span></span><span style="background-color: #fcff01;">newman run 00Test.postman_collection.json --reporters cli,junit --reporter-junit-export Results\junitReport.xml</span></span></div><div style="text-align: left;"><span style="font-size: medium;"><br /><b>Format/Syntax: Postman collection with environment <br /></b><br />
<b style="font-style: italic;"><!--HTML generated using hilite.me--></b></span><div style="background: rgb(248, 248, 248); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; font-style: italic; font-weight: bold; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="font-size: medium;">newman run <span style="color: #666666;"><</span>PostmanCollection.json<span style="color: #666666;">></span> <span style="color: #666666;">-</span>e <span style="color: #666666;"><</span>Environment.json<span style="color: #666666;">></span> <span style="color: #666666;">--</span>reporters cli,junit <span style="color: #666666;">--</span>reporter<span style="color: #666666;">-</span>junit<span style="color: #666666;">-</span><span style="color: green; font-weight: bold;">export</span> Results\junitReport.xml
</span></pre></div>
</div><div style="text-align: left;"><span style="font-size: medium;"><i><br /></i></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbHHgeVOLAfc6ublR8UMJItMfJREhmqTbP5mevqLwVw2-1J02SUJBlj03uo0T3SiuElGZ34sg-a-w2b1Q1Wu41hgsJ0RqqSfDTia8PLjR1aSw-Kj7oDc4ta6dUGK-UQxgyp8BylV1Dw9m9NCIuSfU4eOX8UNnveGaSnog5WoWNLYqek74pyEwZ1nGQQQ/s1531/s2.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: medium;"><img border="0" data-original-height="765" data-original-width="1531" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbHHgeVOLAfc6ublR8UMJItMfJREhmqTbP5mevqLwVw2-1J02SUJBlj03uo0T3SiuElGZ34sg-a-w2b1Q1Wu41hgsJ0RqqSfDTia8PLjR1aSw-Kj7oDc4ta6dUGK-UQxgyp8BylV1Dw9m9NCIuSfU4eOX8UNnveGaSnog5WoWNLYqek74pyEwZ1nGQQQ/w640-h320/s2.png" width="640" /></span></a></div><span style="font-size: medium;"><br /></span><div class="separator" style="clear: both; text-align: center;"><span style="font-size: medium;"><br /></span></div><span style="font-size: medium;">Ensure that the working directory has the code path populated. <br />Default Working Directory format is : <span style="background-color: #fcff01;">$(System.DefaultWorkingDirectory)</span></span></div><div><span style="font-size: medium;"><br /></span><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPdZsAcyrrGqbU4JeuqmVkx0r9m17d9JYWFsooIrBWaIqe5JPkQ_X4fH0oIM1w1C6gTLTux1eYVedDjmRl1iXRN9l51lTrHpAqvnKeOaencut0AV9shOgTgbHMZ4tBeeCMQKT2OhXQmnZ5qnhQMlbyoha153V0Vf9Gf1y_BuTovO8G0KX26xItFGycoQ/s1265/p10.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: medium;"><img border="0" data-original-height="653" data-original-width="1265" height="330" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPdZsAcyrrGqbU4JeuqmVkx0r9m17d9JYWFsooIrBWaIqe5JPkQ_X4fH0oIM1w1C6gTLTux1eYVedDjmRl1iXRN9l51lTrHpAqvnKeOaencut0AV9shOgTgbHMZ4tBeeCMQKT2OhXQmnZ5qnhQMlbyoha153V0Vf9Gf1y_BuTovO8G0KX26xItFGycoQ/w640-h330/p10.png" width="640" /></span></a></div><span style="color: #134f5c; font-size: medium;"><br /></span></div><div><span style="font-size: medium;"><span>Corresponding YAML script</span><!--HTML generated using hilite.me--></span><div style="background: rgb(248, 248, 248); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; text-align: left; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="font-size: medium;">steps:
- script: <span style="color: #ba2121;">'newman</span><span style="color: #19177c;"> </span><span style="color: #ba2121;">run</span><span style="color: #19177c;"> </span><span style="color: #ba2121;">00Test.postman_collection.json</span><span style="color: #19177c;"> </span><span style="color: #ba2121;">--reporters</span><span style="color: #19177c;"> </span><span style="color: #ba2121;">cli,junit</span><span style="color: #19177c;"> </span><span style="color: #ba2121;">--reporter-junit-export</span><span style="color: #19177c;"> </span><span style="color: #ba2121;">Results\junitReport.xml'</span>
displayName: <span style="color: #ba2121;">'Newman</span><span style="color: #19177c;"> </span><span style="color: #ba2121;">command</span><span style="color: #19177c;"> </span><span style="color: #ba2121;">to</span><span style="color: #19177c;"> </span><span style="color: #ba2121;">run</span><span style="color: #19177c;"> </span><span style="color: #ba2121;">tests'</span></span></pre></div></div><div><span><h4><div style="color: black; text-align: left;"><div style="clear: both; text-align: left;"><span style="color: #134f5c;"><br /></span></div><div style="clear: both; text-align: left;"><span style="color: #134f5c;">Publish test results:<br /><ul style="text-align: left;"><li><span style="font-family: Calibri;"><span style="font-weight: normal;">Search for </span><span style="font-weight: normal;">Publish Test Results</span><span style="font-weight: normal;"> plugin and add it as next task for the job. <br /></span></span></li><li><span style="font-family: Calibri; font-weight: normal;">Configure the below basic properties </span></li><li><span style="font-family: Calibri; font-weight: normal;">Display Name : Publish Test Results **/TEST-*.xml ( It could be any name, I used the generated name)</span></li><li><span style="font-family: Calibri; font-weight: normal;">Test result format : Junit</span></li><li><span style="font-family: Calibri; font-weight: normal;">Test results files: $(System.DefaultWorkingDirectory)\Results\*.xml </span></li><li><span style="font-family: Calibri; font-weight: normal;">Search folder : $(System.DefaultWorkingDirectory)</span></li></ul></span></div><div class="separator" style="clear: both; font-size: large; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-OUkpfIvRIdlXhciJGjqTW1JQQj8V2H0cMLc4zfNDBXGhz5uV_zohEsP0C4JB6HTfH5XTsQ4XLcR_WAuIdN4Vg_yiQ7JyptBVxyr3pDvAkX_Ghc_xUcgSwLvYsyoROLjAHEuEDVOpWz_LmZwaPqgI4fQpzcQmeBg1gndrV-0b86_nbNdvKJ2-dEJaog/s822/s3.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="491" data-original-width="822" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-OUkpfIvRIdlXhciJGjqTW1JQQj8V2H0cMLc4zfNDBXGhz5uV_zohEsP0C4JB6HTfH5XTsQ4XLcR_WAuIdN4Vg_yiQ7JyptBVxyr3pDvAkX_Ghc_xUcgSwLvYsyoROLjAHEuEDVOpWz_LmZwaPqgI4fQpzcQmeBg1gndrV-0b86_nbNdvKJ2-dEJaog/w400-h239/s3.png" width="400" /></a></div><p style="color: black; font-size: large; text-align: left;"><br /></p></div><div style="color: black; font-size: large; text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHoY_6JZyL84S0o1-0tQ90gIr6-HEWV7Lz_ifpd2rf1cioO1rxTnPo7ToEK2OMxoDqxvS9rYJlPqqugBMY-yWVAXHfAX7oR_G6-QJFkdmVFcPAeHeJfQHf-Y6JePI4PjHzN6wINO3_pgOUGbUxrGYnxccqv070auSGx7NygCFMZQ1o6GzRAl1eT4BLaQ/s1554/publish.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="767" data-original-width="1554" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHoY_6JZyL84S0o1-0tQ90gIr6-HEWV7Lz_ifpd2rf1cioO1rxTnPo7ToEK2OMxoDqxvS9rYJlPqqugBMY-yWVAXHfAX7oR_G6-QJFkdmVFcPAeHeJfQHf-Y6JePI4PjHzN6wINO3_pgOUGbUxrGYnxccqv070auSGx7NygCFMZQ1o6GzRAl1eT4BLaQ/w640-h316/publish.png" width="640" /></a></div><br /><span style="font-weight: normal;"><br /></span></div></h4></span></div><h3 style="text-align: left;"><span style="font-size: medium;">Save the pipe line and Queue(run the pipeline) <br /></span><div style="text-align: left;"><span><span style="font-size: medium; font-weight: normal;">Save the pipe line</span></span></div><div style="text-align: left;"><span style="font-size: medium;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWmPL8Xg5BFb75PIQ-2zPKKzG3ysy0Y-_C3H7unM_cX2hp6Yn_ZGBBctuasdstbvx4e4B6Q_XrImw_tZI-YLXSQTgOECHuG8BcLzit4kM0Ct-6C92SnaiJ3Saz7qAoIF3Rj3EQEUGdsTPHH4LG_P59FCND1uN1ztXXIon8uxqO3GSLKgdIxhLmxgkZYw/s1122/save.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="228" data-original-width="1122" height="130" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWmPL8Xg5BFb75PIQ-2zPKKzG3ysy0Y-_C3H7unM_cX2hp6Yn_ZGBBctuasdstbvx4e4B6Q_XrImw_tZI-YLXSQTgOECHuG8BcLzit4kM0Ct-6C92SnaiJ3Saz7qAoIF3Rj3EQEUGdsTPHH4LG_P59FCND1uN1ztXXIon8uxqO3GSLKgdIxhLmxgkZYw/w640-h130/save.png" width="640" /></a></div><br /><span style="font-weight: normal;">Queue and run the pipe line <br /><br /></span><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI-DPqJKdPU1igh_0HmeCdbFcleEUQ2oQyeHm1F2SVBKjjZVKcFZMWzLBzFY8O8EVF_S7z8sFjrNYlrnZ75581Vl1sdVBiY1CMGrM8IoX78U_BGubewS8Be2tlHBIe3KbbE4pCQ2IgemQv5JCPrcjTJz2aNfAIsOR1Xh4dTQCjyIssKzmfh_xcZylgUg/s1063/queue.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1063" data-original-width="794" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI-DPqJKdPU1igh_0HmeCdbFcleEUQ2oQyeHm1F2SVBKjjZVKcFZMWzLBzFY8O8EVF_S7z8sFjrNYlrnZ75581Vl1sdVBiY1CMGrM8IoX78U_BGubewS8Be2tlHBIe3KbbE4pCQ2IgemQv5JCPrcjTJz2aNfAIsOR1Xh4dTQCjyIssKzmfh_xcZylgUg/w478-h640/queue.png" width="478" /></a></div><br /></span></div><div style="text-align: left;"><span><span style="font-size: medium; font-weight: normal;">As the pipe line queued we navigate to the run console of the pipe line, from this console click on "Agent job1" in the bottom which is in process. </span></span></div><div style="text-align: left;"><span><span style="font-size: medium; font-weight: normal;"><br /></span></span></div><div style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIDMbbv4UGEwAHWwNyFkUciZDBlxesKG3J7acKdUry3i6BHGVW0tjjm3aLRkE-5RTT-OnCzQSTe7caKOmgbUTanoRjSHo_24pa-9t3cESjGRa1fJgzl0JFGhsXstAgOR9cPE2BstTldFqxNWX44OMdt42GxSrAPXMei8qe8zr5w3qWB2L3gPJd0cgQbw/s1860/queue.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: medium;"><img border="0" data-original-height="662" data-original-width="1860" height="228" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIDMbbv4UGEwAHWwNyFkUciZDBlxesKG3J7acKdUry3i6BHGVW0tjjm3aLRkE-5RTT-OnCzQSTe7caKOmgbUTanoRjSHo_24pa-9t3cESjGRa1fJgzl0JFGhsXstAgOR9cPE2BstTldFqxNWX44OMdt42GxSrAPXMei8qe8zr5w3qWB2L3gPJd0cgQbw/w640-h228/queue.png" width="640" /></span></a></div><div style="text-align: left;"><span><span style="font-size: medium; font-weight: 400;"><br /></span></span></div><div style="text-align: left;"><span style="font-size: medium;"><span style="font-weight: 400;">Agent job1 displays the tasks to perform by the pipeline as shown in below image. This includes the default tasks along with the tasks configured by us. <br /><br /></span><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsJ6fxiGHgfWr1PRk6JFNe5Qc2cP9ly9O2zmgS-hdI3UwUV8c8dI19pE0SsffoqZIqbNktTS0hkrh5PADxBvDI_XqNsENHsjlJXFg47YtGjbjZ4D078dW2QjuSaUGro0vJFxrNiJ17gp8ipmYX79jlL-kDEAWbLDBhElDwK75jvTPoyL7vpD3e1ok0Zw/s1551/execution.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="873" data-original-width="1551" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsJ6fxiGHgfWr1PRk6JFNe5Qc2cP9ly9O2zmgS-hdI3UwUV8c8dI19pE0SsffoqZIqbNktTS0hkrh5PADxBvDI_XqNsENHsjlJXFg47YtGjbjZ4D078dW2QjuSaUGro0vJFxrNiJ17gp8ipmYX79jlL-kDEAWbLDBhElDwK75jvTPoyL7vpD3e1ok0Zw/w640-h360/execution.png" width="640" /></a></div><br /></span></div><span><span style="font-size: medium; font-weight: 400;">All the tasks in the job has successfully ran so the next thing is to analyze the junit report. </span></span></div><span style="font-size: medium;"> <br />Analysis of Junit Report</span></h3><div><span style="font-size: medium;">Be on the pipe line run console to view the report. </span></div><div><span style="font-size: medium;">If there are any unexpected blockers while executing the tasks, the junit report will not be generated. </span></div><div><span style="font-size: medium;">If there are any failures in the asserstions/tests for the postman junit report will be generated. <br /><br />The report can be analyzed in the <b>Tests </b>tab as shown in below image.</span></div><div><span style="font-size: medium;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizLdeY2KZzjtfjtXjbTLe7oke3DZqUWlRtUGhsweDovXzL28ct111jdTVzoJwaw_XFgEga0KeRURYmYkLAHsgobpCM2jokhO1eps2HbWWY10WUaO023CQ7rAXAE9QsiFcn4BCSegjaR2TrxlsGgo8NxuRJBZYWgR33QtfC2vrS202zigVxFnEs2OzO_w/s1538/junit%20report.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: medium;"><img border="0" data-original-height="686" data-original-width="1538" height="286" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizLdeY2KZzjtfjtXjbTLe7oke3DZqUWlRtUGhsweDovXzL28ct111jdTVzoJwaw_XFgEga0KeRURYmYkLAHsgobpCM2jokhO1eps2HbWWY10WUaO023CQ7rAXAE9QsiFcn4BCSegjaR2TrxlsGgo8NxuRJBZYWgR33QtfC2vrS202zigVxFnEs2OzO_w/w640-h286/junit%20report.png" width="640" /></span></a></div><span style="font-size: medium;"><br /></span><div class="separator" style="clear: both; text-align: center;"><span style="font-size: medium;"><br /></span></div><div class="separator" style="clear: both; text-align: left;"><h3><span style="font-size: medium;">Analysis of Published Report<br /></span><div style="text-align: left;"><span><span style="font-size: medium; font-weight: normal;">Click on Publish Test Results task from the pipe line execution and the console make note of the URL where the results are published. </span></span></div><div style="text-align: left;"><span><span style="font-size: medium; font-weight: normal;">Open the URL in a new tab and start analyzing the results. </span></span></div></h3><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjzDiZQEJF_sdvGDKP6tBumum46yetesw5GLFdVVoDf-zkyUNu26bv3Gz5Oqo3z95fUJDFOzgQpQiWc-zTgCwlr661WrZEYVVzJhWNg5VA_KAPKRBSU3NS6CVtktBeeYFEvhnLxNtkQXc4bhM87GCXSKAyxp22pjEKiOu1criVMUIJODPUVGvH_Ym2Ag/s1531/p11.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: medium;"><img border="0" data-original-height="695" data-original-width="1531" height="290" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjzDiZQEJF_sdvGDKP6tBumum46yetesw5GLFdVVoDf-zkyUNu26bv3Gz5Oqo3z95fUJDFOzgQpQiWc-zTgCwlr661WrZEYVVzJhWNg5VA_KAPKRBSU3NS6CVtktBeeYFEvhnLxNtkQXc4bhM87GCXSKAyxp22pjEKiOu1criVMUIJODPUVGvH_Ym2Ag/w640-h290/p11.png" width="640" /></span></a></div><span style="font-size: medium;"><br /></span><div><span style="font-size: medium;"><br /></span></div></div><span style="font-size: medium;">Go to the <b>Runs </b>section from Azure DevOps wizard as shown in below and start analyzing the published report. </span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIUmWHpzxVVXMjjMG4v6yzUyzTZWSppAPcD72IOP_tAxDKSxdEy5I8MzO-LEn5Wx3B5gV3UpA6Jh8AT3E4loSlaijF-V43pJjc2Fu_GiqeyzoatqzXVnq5x5_kBvlZX1qPu2ckf3URc2nVOFuQHn3EUHgOdUYM_rQfgn8bPejKxQYrzYklX9iN-pI4pA/s1846/p12.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: medium;"><img border="0" data-original-height="868" data-original-width="1846" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIUmWHpzxVVXMjjMG4v6yzUyzTZWSppAPcD72IOP_tAxDKSxdEy5I8MzO-LEn5Wx3B5gV3UpA6Jh8AT3E4loSlaijF-V43pJjc2Fu_GiqeyzoatqzXVnq5x5_kBvlZX1qPu2ckf3URc2nVOFuQHn3EUHgOdUYM_rQfgn8bPejKxQYrzYklX9iN-pI4pA/w640-h300/p12.png" width="640" /></span></a></div><span style="font-size: medium;"><br /></span><div><span style="font-size: medium;"><br /></span><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifQlUNriLSgA_CXN07EXQc19MWpNDePBLNu1v33k_mQFwKZOuTrqO8dA6GoPo9UULimk5AuxCANPqJRtWr3IysezzzfddEvidOwVtgG02xlFcxRjEn7bQKcm2tJdi58apd2TWDHVS_AJtDJlr6gEoiwMcIh-Q9uIv7anUFdwnXn0u0tYEDZite-eF6bA/s1577/summary.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: medium;"><img border="0" data-original-height="338" data-original-width="1577" height="138" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifQlUNriLSgA_CXN07EXQc19MWpNDePBLNu1v33k_mQFwKZOuTrqO8dA6GoPo9UULimk5AuxCANPqJRtWr3IysezzzfddEvidOwVtgG02xlFcxRjEn7bQKcm2tJdi58apd2TWDHVS_AJtDJlr6gEoiwMcIh-Q9uIv7anUFdwnXn0u0tYEDZite-eF6bA/w640-h138/summary.png" width="640" /></span></a></div><div style="text-align: left;"><span style="font-size: medium;">In case of any test failures, Create bug or update the result to to the test case! </span></div></div><div style="text-align: left;"><span style="font-size: medium;"><br /></span></div><div style="text-align: left;"><span style="font-size: medium;">This is how we integrate postman/newman API tests in Azure DevOps pipe line for the continuous integration (CI) .</span></div><div style="text-align: left;"><span style="font-size: medium;"><br /></span></div><div style="text-align: left;"><span style="font-size: medium;">I hope this helped a bit, keep an eye on this portal for more automation updates.</span></div></div>Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0tag:blogger.com,1999:blog-8484056338095754480.post-45661896950557261492022-08-11T12:33:00.004+05:302023-06-14T18:30:24.767+05:30org.openqa.selenium.InvalidSelectorException | Xpath text() method returns InvalidSelectorException<p></p><ul style="text-align: left;"><li> Xpath's <b>text()</b> returns the text of selected element and it doesn't fit into the WebElement's findElement method. <br /><br /></li><li>So remove the text() from the xpath and then apply the getText() method on WebElement. <br /><br /></li><li><b>For example: <br />//*[@id="formsearch"]/fieldset/legend/text()</b> will identify the text of the WebElement and we can't use it for findElement instead<br /><br /><b>//*[@id="formsearch"]/fieldset/legend </b>will identify the WebElement and then on this we can use getText() method of the element. </li></ul><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;">org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">InvalidSelectorException</span><span style="color: #333333;">:</span> invalid <span style="color: #997700; font-weight: bold;">selector:</span> The result of the xpath expression <span style="background-color: #fff0f0;">"//*[@id="</span>formsearch<span style="background-color: #fff0f0;">"]/fieldset/legend/text()"</span> <span style="color: #997700; font-weight: bold;">is:</span> <span style="color: #333333;">[</span>object Text<span style="color: #333333;">].</span> It should be an element<span style="color: #333333;">.</span>
<span style="color: #333333;">(</span>Session <span style="color: #997700; font-weight: bold;">info:</span> chrome<span style="color: #333333;">=</span><span style="color: #6600ee; font-weight: bold;">104.0</span><span style="color: #333333;">.</span><span style="color: #6600ee; font-weight: bold;">5112.81</span><span style="color: #333333;">)</span>
For documentation on <span style="color: #008800; font-weight: bold;">this</span> error<span style="color: #333333;">,</span> please <span style="color: #997700; font-weight: bold;">visit:</span> <span style="color: #997700; font-weight: bold;">https:</span><span style="color: #888888;">//selenium.dev/exceptions/#invalid_selector_exception</span>
Build <span style="color: #997700; font-weight: bold;">info:</span> <span style="color: #997700; font-weight: bold;">version:</span> <span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">revision:</span> <span style="background-color: #ffaaaa; color: red;">'</span>a4995e2c09<span style="color: #333333;">*</span><span style="background-color: #ffaaaa; color: red;">'</span>
System <span style="color: #997700; font-weight: bold;">info:</span> <span style="color: #997700; font-weight: bold;">host:</span> <span style="background-color: #ffaaaa; color: red;">'</span>SADAKARP<span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">ip:</span> <span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #6600ee; font-weight: bold;">200.123</span><span style="color: #333333;">.</span><span style="color: #6600ee; font-weight: bold;">4.3</span><span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> os<span style="color: #333333;">.</span><span style="color: #0000cc;">name</span><span style="color: #333333;">:</span> <span style="background-color: #ffaaaa; color: red;">'</span>Windows <span style="color: #0000dd; font-weight: bold;">11</span><span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> os<span style="color: #333333;">.</span><span style="color: #0000cc;">arch</span><span style="color: #333333;">:</span> <span style="background-color: #ffaaaa; color: red;">'</span>amd64<span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> os<span style="color: #333333;">.</span><span style="color: #0000cc;">version</span><span style="color: #333333;">:</span> <span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #6600ee; font-weight: bold;">10.0</span><span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #333333;">,</span> java<span style="color: #333333;">.</span><span style="color: #0000cc;">version</span><span style="color: #333333;">:</span> <span style="background-color: #ffaaaa; color: red;">'</span><span style="color: #6600ee; font-weight: bold;">17.0</span><span style="color: #333333;">.</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="background-color: #ffaaaa; color: red;">'</span>
Driver <span style="color: #997700; font-weight: bold;">info:</span> org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">chrome</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ChromeDriver</span>
<span style="color: #997700; font-weight: bold;">Command:</span> <span style="color: #333333;">[</span>f12f1c7e2c818403564e8712964c6af2<span style="color: #333333;">,</span> findElement <span style="color: #333333;">{</span>using<span style="color: #333333;">=</span>xpath<span style="color: #333333;">,</span> value<span style="color: #333333;">=</span><span style="color: #888888;">//*[@id="formsearch"]/fieldset/legend/text()}]</span>
Capabilities <span style="color: #333333;">{</span><span style="color: #997700; font-weight: bold;">acceptInsecureCerts:</span> <span style="color: #008800; font-weight: bold;">false</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">browserName:</span> chrome<span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">browserVersion:</span> <span style="color: #6600ee; font-weight: bold;">104.0</span><span style="color: #333333;">.</span><span style="color: #6600ee; font-weight: bold;">5112.81</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">chrome:</span> <span style="color: #333333;">{</span><span style="color: #997700; font-weight: bold;">chromedriverVersion:</span> <span style="color: #6600ee; font-weight: bold;">104.0</span><span style="color: #333333;">.</span><span style="color: #6600ee; font-weight: bold;">5112.79</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span>cf3e8c8a07d<span style="color: #333333;">...,</span> <span style="color: #997700; font-weight: bold;">userDataDir:</span> <span style="color: #997700; font-weight: bold;">C:</span><span style="background-color: #ffaaaa; color: red;">\</span>Users<span style="background-color: #ffaaaa; color: red;">\</span>sadakarp<span style="background-color: #ffaaaa; color: red;">\</span>AppData<span style="background-color: #ffaaaa; color: red;">\</span>L<span style="color: #333333;">...},</span> <span style="color: #997700; font-weight: bold;">goog:chromeOptions:</span> <span style="color: #333333;">{</span><span style="color: #997700; font-weight: bold;">debuggerAddress:</span> <span style="color: #997700; font-weight: bold;">localhost:</span><span style="color: #0000dd; font-weight: bold;">65004</span><span style="color: #333333;">},</span> <span style="color: #997700; font-weight: bold;">networkConnectionEnabled:</span> <span style="color: #008800; font-weight: bold;">false</span><span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">pageLoadStrategy:</span> normal<span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">platformName:</span> WINDOWS<span style="color: #333333;">,</span> <span style="color: #997700; font-weight: bold;">proxy:</span> Proxy<span style="color: #333333;">(),</span> <span style="color: #997700; font-weight: bold;">se:cdp:</span> <span style="color: #997700; font-weight: bold;">ws:</span><span style="color: #888888;">//localhost:65004/devtoo..., se:cdpVersion: 104.0.5112.81, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}</span>
Session <span style="color: #997700; font-weight: bold;">ID:</span> f12f1c7e2c818403564e8712964c6af2
at java<span style="color: #333333;">.</span><span style="color: #0000cc;">base</span><span style="color: #333333;">/</span>jdk<span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">reflect</span><span style="color: #333333;">.</span><span style="color: #0000cc;">NativeConstructorAccessorImpl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">newInstance0</span><span style="color: #333333;">(</span>Native Method<span style="color: #333333;">)</span>
at java<span style="color: #333333;">.</span><span style="color: #0000cc;">base</span><span style="color: #333333;">/</span>jdk<span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">reflect</span><span style="color: #333333;">.</span><span style="color: #0000cc;">NativeConstructorAccessorImpl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">newInstance</span><span style="color: #333333;">(</span>NativeConstructorAccessorImpl<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">77</span><span style="color: #333333;">)</span>
at java<span style="color: #333333;">.</span><span style="color: #0000cc;">base</span><span style="color: #333333;">/</span>jdk<span style="color: #333333;">.</span><span style="color: #0000cc;">internal</span><span style="color: #333333;">.</span><span style="color: #0000cc;">reflect</span><span style="color: #333333;">.</span><span style="color: #0000cc;">DelegatingConstructorAccessorImpl</span><span style="color: #333333;">.</span><span style="color: #0000cc;">newInstance</span><span style="color: #333333;">(</span>DelegatingConstructorAccessorImpl<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">45</span><span style="color: #333333;">)</span>
at java<span style="color: #333333;">.</span><span style="color: #0000cc;">base</span><span style="color: #333333;">/</span>java<span style="color: #333333;">.</span><span style="color: #0000cc;">lang</span><span style="color: #333333;">.</span><span style="color: #0000cc;">reflect</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Constructor</span><span style="color: #333333;">.</span><span style="color: #0000cc;">newInstanceWithCaller</span><span style="color: #333333;">(</span>Constructor<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">499</span><span style="color: #333333;">)</span>
at java<span style="color: #333333;">.</span><span style="color: #0000cc;">base</span><span style="color: #333333;">/</span>java<span style="color: #333333;">.</span><span style="color: #0000cc;">lang</span><span style="color: #333333;">.</span><span style="color: #0000cc;">reflect</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Constructor</span><span style="color: #333333;">.</span><span style="color: #0000cc;">newInstance</span><span style="color: #333333;">(</span>Constructor<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">480</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">codec</span><span style="color: #333333;">.</span><span style="color: #0000cc;">w3c</span><span style="color: #333333;">.</span><span style="color: #0000cc;">W3CHttpResponseCodec</span><span style="color: #333333;">.</span><span style="color: #0000cc;">createException</span><span style="color: #333333;">(</span>W3CHttpResponseCodec<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">200</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">codec</span><span style="color: #333333;">.</span><span style="color: #0000cc;">w3c</span><span style="color: #333333;">.</span><span style="color: #0000cc;">W3CHttpResponseCodec</span><span style="color: #333333;">.</span><span style="color: #0000cc;">decode</span><span style="color: #333333;">(</span>W3CHttpResponseCodec<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">133</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">codec</span><span style="color: #333333;">.</span><span style="color: #0000cc;">w3c</span><span style="color: #333333;">.</span><span style="color: #0000cc;">W3CHttpResponseCodec</span><span style="color: #333333;">.</span><span style="color: #0000cc;">decode</span><span style="color: #333333;">(</span>W3CHttpResponseCodec<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">53</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">HttpCommandExecutor</span><span style="color: #333333;">.</span><span style="color: #0000cc;">execute</span><span style="color: #333333;">(</span>HttpCommandExecutor<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">184</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">service</span><span style="color: #333333;">.</span><span style="color: #0000cc;">DriverCommandExecutor</span><span style="color: #333333;">.</span><span style="color: #0000cc;">invokeExecute</span><span style="color: #333333;">(</span>DriverCommandExecutor<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">167</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">service</span><span style="color: #333333;">.</span><span style="color: #0000cc;">DriverCommandExecutor</span><span style="color: #333333;">.</span><span style="color: #0000cc;">execute</span><span style="color: #333333;">(</span>DriverCommandExecutor<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">142</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteWebDriver</span><span style="color: #333333;">.</span><span style="color: #0000cc;">execute</span><span style="color: #333333;">(</span>RemoteWebDriver<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">569</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ElementLocation</span>$ElementFinder$2<span style="color: #333333;">.</span><span style="color: #0000cc;">findElement</span><span style="color: #333333;">(</span>ElementLocation<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">162</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">ElementLocation</span><span style="color: #333333;">.</span><span style="color: #0000cc;">findElement</span><span style="color: #333333;">(</span>ElementLocation<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">60</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteWebDriver</span><span style="color: #333333;">.</span><span style="color: #0000cc;">findElement</span><span style="color: #333333;">(</span>RemoteWebDriver<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">387</span><span style="color: #333333;">)</span>
at org<span style="color: #333333;">.</span><span style="color: #0000cc;">openqa</span><span style="color: #333333;">.</span><span style="color: #0000cc;">selenium</span><span style="color: #333333;">.</span><span style="color: #0000cc;">remote</span><span style="color: #333333;">.</span><span style="color: #0000cc;">RemoteWebDriver</span><span style="color: #333333;">.</span><span style="color: #0000cc;">findElement</span><span style="color: #333333;">(</span>RemoteWebDriver<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">379</span><span style="color: #333333;">)</span>
at com<span style="color: #333333;">.</span><span style="color: #0000cc;">sadakar</span><span style="color: #333333;">.</span><span style="color: #0000cc;">cucumber</span><span style="color: #333333;">.</span><span style="color: #0000cc;">stepdef</span><span style="color: #333333;">.</span><span style="color: #0000cc;">payers</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Products</span><span style="color: #333333;">.</span><span style="color: #0000cc;">routeToolPageNavigationValidation</span><span style="color: #333333;">(</span>Products<span style="color: #333333;">.</span><span style="color: #0000cc;">java</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">45</span><span style="color: #333333;">)</span>
at <span style="background-color: #ffaaaa; color: red;">✽</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Search</span> <span style="color: #008800; font-weight: bold;">for</span> Medicaid Florida <span style="color: #333333;">(</span>FL<span style="color: #333333;">)</span> payer and navigate to RouteTool page<span style="color: #333333;">(</span><span style="color: #997700; font-weight: bold;">classpath:</span>features<span style="color: #333333;">/</span>Products<span style="color: #333333;">.</span><span style="color: #0000cc;">feature</span><span style="color: #333333;">:</span><span style="color: #0000dd; font-weight: bold;">12</span><span style="color: #333333;">)</span>
</pre></div>
Sadakar Pochampallihttp://www.blogger.com/profile/13590828239755256167noreply@blogger.com0