Planet Jaspersoft

Filter by tags:

July 14, 2020

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

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

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


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

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

July 14, 2020

July 10, 2020

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

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

  

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



 

July 10, 2020

July 6, 2020

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

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

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


Sample screenshot: 


Sample output: 


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

July 6, 2020

July 1, 2020

Sample Design


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

References:

JRXML: (Version 7.2 pro)

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



July 1, 2020

June 5, 2020

Hi,


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

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


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

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

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



DataTableButtonsNavigationActualVsDisplayedRowCount.java
package selenium.datatables;

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

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

@SuppressWarnings("unused")
public class DataTableButtonsNavigationActualVsDisplayedRowCount {

public static WebDriver driver;

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

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

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

public static void compareDispalyedRowCountToActualRowCount() throws Exception {

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

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

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

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

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

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

Thread
.sleep(1000);

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

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

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

June 5, 2020

June 4, 2020

Hi,

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

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

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

June 4, 2020

May 28, 2020

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

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

Zoom-In by tapping the image:

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

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

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

Select entriesDropDown = new Select(entriesDropDownLocator);

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

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

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

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

CompareDisplayedDropdownSelectValuesWithActualValues.java
package selenium.datatables;

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


public class CompareDisplayedDropdownSelectValuesWithActualValues {

public static WebDriver driver;

public void compareDispalyedRowCountToActualRowCount() throws Exception {

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

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

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

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

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

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

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

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

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

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

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

CompareDisplayedDropdownSelectValuesWithActualValues c = new CompareDisplayedDropdownSelectValuesWithActualValues();

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

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

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

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

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

May 28, 2020

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

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

We will see the latter implementation in this post.

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

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

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

JavascriptExecutor js
=(JavascriptExecutor)driver;

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

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

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

int displayedCountOfRowsOnPage = Integer.parseInt(displayedCount);

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

CompareDisplayedRowCountToDataTableRowCount.java
package selenium.datatables;


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

public class CompareDisplayedRowCountToDataTableRowCount {

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

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

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


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

int dataTableActualRowCount=0;

JavascriptExecutor js=(JavascriptExecutor)driver;

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

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

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

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


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

- Sadakar Pochampalli

May 28, 2020

May 26, 2020

Hi, in this post, we will walk through the usage and live example of isEnabled() method. isEnabled() method, we apply in special scenarios where in we select a check box and get the status of a button i.e., enabled or disabled. Let's take a look into the following example.

isEnabled()
  • To verify if an element is enabled or disabled on web-page. 
  • Returns "ture" if element is enabled and returns "false" if an element is disabled. 
  • Examples: Mostly used with button elements, locked/disabled text input elements.
Problem Statement : 
Display the status of "Sign up" button - The below two images gives an idea on how the button looks before enabled and after enabled after selecting a check box.

Sign up  button before enabled i.e., before selecting check box "I have read...." 
Tap on the image to get better visibility:
Sign up  button after enabled i.e., after selecting check box "I have read...." 
Tap on the image to get better visibility:
The below piece of selenium script does
    a) verifies the status of "Sign up" button before enabled.
    b) selects the check box "I have read..." and
    c)  verifies the status of "Sign up" button after selecting the  check box.

//isEnabled() example - before selecting the check box
//display the enable or disable status of "Sign Up" button before selecting the check box
WebElement signUp
= driver.findElement(By.xpath("//button[@id='signup']"));
boolean b1 = signUp.isEnabled();//false
System
.out.println("Sign Up button enable/disable before selecting \"I have read and accpet...\" check box = "+b1);


//select the "I have read and accept check box
WebElement element
=driver.findElement(By.xpath("//input[@id='termsAndPrivacy']"));
WebDriverWait wait
= new WebDriverWait(driver, 60);
wait
.until(ExpectedConditions.visibilityOf(element));
new Actions(driver).moveToElement(element, 1, 1).click().perform();

//isEnabled() example - check box
//display the enable or disable status of "Sign Up" button after selecting the check box
boolean b2 = signUp.isEnabled();//true
System
.out.println("Sign Up button enable/disable after selecting \"I have read and accpet...\" check box = "+b2);

Watch this ~ 6 min video tutorial for the demo : 


WebElementInterfaceMethod_isEnabledDemo.java
package selenium.webelement.methods;

/* button isEnabled() demo */

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class WebElementInterfaceMethod_isEnabledDemo {

public static void main(String[] args) {

WebDriver driver;

//loading Chrome driver from physical drive
System.setProperty("webdriver.chrome.driver", "D:\\006_trainings\\chromedriver.exe");

System.setProperty("webdriver.chrome.silentOutput", "true");
//System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true");

//launch the browser
driver = new ChromeDriver();

//navigate to site
driver.navigate().to("https://us.megabus.com/account-management/login");

//maximize the browser
driver.manage().window().maximize();

//close the message on site
driver.findElement(By.xpath("//i[@class='close mb-close']")).click();

// Sign Up form
WebElement signUpFromTab = driver.findElement(By.xpath("//a[@class='btn btn-link btn-block'][contains(text(),'Sign up')]"));
signUpFromTab.click();

//Email
WebElement email = driver.findElement(By.xpath("//input[@id='email']"));
email.sendKeys("java.selenium2023@gmail.com");

//Confirm Email
WebElement confirmEmail = driver.findElement(By.xpath("//input[@id='confirmEmail']"));
confirmEmail.sendKeys("java.selenium2023@gmail.com");

//Choose a Password
WebElement chooseAPassword = driver.findElement(By.xpath("//input[@id='choosePassword']"));
chooseAPassword.sendKeys("JavaSelenium2023");

//Confirm Password
WebElement confirmPassword = driver.findElement(By.xpath("//input[@id='confirmPassword']"));
confirmPassword.sendKeys("JavaSelenium2023");

//isEnabled() example - before selecting the check box
//display the enable or disable status of "Sign Up" button before selecting the check box
WebElement signUp = driver.findElement(By.xpath("//button[@id='signup']"));
boolean b1 = signUp.isEnabled();
System.out.println("Sign Up button enable/disable before selecting \"I have read and accpet...\" check box = "+b1);


//select the "I have read and accept check box
WebElement element=driver.findElement(By.xpath("//input[@id='termsAndPrivacy']"));
WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.visibilityOf(element));
new Actions(driver).moveToElement(element, 1, 1).click().perform();

//isEnabled() example - check box
//display the enable or disable status of "Sign Up" button after selecting the check box
boolean b2 = signUp.isEnabled();
System.out.println("Sign Up button enable/disable after selecting \"I have read and accpet...\" check box = "+b2);

signUp.click();

//close the browser
//driver.close();

//close all the browsers opened by WebDriver during execution and quit the session
//driver.quit();
}
}


To know more about isDisplayed() or isSelected() methods, please visit this post @

WebElement interface methods examples in selenium - part 2 | Understanding of methods isDisplayed() Vs isEnabled() Vs isSelected()


isDisplayed()
  • To verify presence of a web-element with in the web page. 
  • This method returns either true or false boolean values. 
  • If the element is present it returns "true" otherwise it returns "false". 
  • This method avoids the problem of having to parse an element's "style" attribute.
  • Example : This method can be applicable for all the elements on web-page. 
 isSelected()
  • Returns whether an element say check box or radio button is selected or not. 
  • If selected returns "true", if not selected returns "false". 
  • Examples: Check boxes, drop downs , radio buttons 
I hope this helps someone in the community, stay tuned for more automation.

    May 26, 2020

    May 23, 2020

    Hi, in this page, we will discuss about Actions(class) and Action(interface) and keyboard events example in selenium with some key take away notes.

    For, mouse events tutorial, click this link.



    Actions

    • It is a class and the package is org.openqa.selenium.interactions.Actions
    • It represents collection of individual Action that you want to perform.
    • Using this class we can handle keyboard and mouse events. i.e., 
      • Keyboard interface methods 
      • Mouse interface methods 

    Action 

    • Action is an interface 
    • It represents single user interaction. 
    • Using this interface, on the Actions object we perform series of actions. 
    • Most widely and must use method is perform() after creating series of actions and storing in Action   

    Keyboard events examples 

    keyDown --> for instance, Pressing a Shift key
    keyUp    --> for instance, Releasing a pressed Shift key
    sendKeys --> used to send series of characters as text

    Use case : Search text "Actions(class) and Action(interface) in selenium" in this site @ https://jasper-bi-suite.blogspot.com/ by sending the text in Capital letters. 

    1. Locate the "search box" element and store it in WebElement variable. 
    2. Create object "actionsBuilder" for Actions class and pass "driver" in its constructor.
    3.  Build the series of actions on "actionBuilder" object and store it in "Action" interface variable "seriesOfKeyBoardActions" and apply build() method once the series of actions are done.
    4. Perform the series actions using "perform()" method on the above created Action variable say "seriesOfKeyBoardActions" 
    Click on the images to enlarge: 

    The code snippet below holds shifts key and converts the text into capital letters using "keyDown" event and then releases the shift key using "keyUp" event.

    //Search box element locator 
    WebElement searchBox
    = driver.findElement(By.xpath("//input[@name='q']"));

    //Actions object
    Actions actionsBuilder
    = new Actions(driver);

    //Building the series of actions
    Action seriesOfKeyBoardActions
    = actionsBuilder
    .moveToElement(searchBox) //Moves the mouse pointer to the center of the element
    .click() //perform click on the serach box
    .keyDown(searchBox,Keys.SHIFT) // Pressing shift key
    .sendKeys(searchBox,"Actions(class) and Action(interface) in selenium") //sending search text
    .keyUp(searchBox,Keys.SHIFT) // Releasing shift key
    .build(); // building all the above 5 actions

    //Performing the built actions
    seriesOfKeyBoardActions
    .perform();

    Watch this space for walk through video tutorial for below use-case:

    KeyboardEventsSendCaptialLettersForSearchingActionsArcticle.java
    /* Keyboard events demo */
    package keyboard.events.examples;

    import org.openqa.selenium.By;
    import org.openqa.selenium.Keys;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.interactions.Action;
    import org.openqa.selenium.interactions.Actions;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;

    public class KeyboardEventsSendCaptialLettersForSearchingActionsArcticle {

    public static void main(String[] args) {

    WebDriver driver;

    //loading Chrome driver from physical drive
    System.setProperty("webdriver.chrome.driver", "D:\\006_trainings\\chromedriver_83.exe");
    System.setProperty("webdriver.chrome.silentOutput", "true");

    //launch the browser
    driver = new ChromeDriver();

    //navigate to site
    driver.navigate().to("https://jasper-bi-suite.blogspot.com/");

    //maximize the browser
    driver.manage().window().maximize();

    //Search box element locator
    WebElement searchBox = driver.findElement(By.xpath("//input[@name='q']"));

    //Actions object
    Actions actionsBuilder = new Actions(driver);

    //Building the series of actions
    Action seriesOfKeyBoardActions = actionsBuilder
    .moveToElement(searchBox) //Moves the mouse pointer to the center of the element
    .click() //perform click on the serach box
    .keyDown(searchBox,Keys.SHIFT) // Pressing shift key
    .sendKeys(searchBox,"Actions(class) and Action(interface) in selenium") //sending search text
    .keyUp(searchBox,Keys.SHIFT) // Releasing shift key
    .build(); // building all the above 5 actions

    //Performing the built actions
    seriesOfKeyBoardActions.perform();

    //click on Search button
    WebElement searchButton = driver.findElement(By.xpath("//input[@class='gsc-search-button']"));
    searchButton.click();

    //close the browser
    //driver.close();

    //close all the browsers opened by WebDriver during execution and quit the session
    //driver.quit();
    }
    }

    Stay tuned for more automation!

    - Sadakar Pochampalli

    May 23, 2020

    Pages

    Feedback