by admin | Feb 28, 2017 | Automation Testing, Blog |
Suppose if you want to compare the screenshot (source) which was captured in your last automated test execution with the current execution screenshot (target), then you can go with imagemagick tool. It provides the difference in a file after a comparison and is very helpful for automation testing.
You can also use ImageMagick to compare two different images through command line if you have any test cases for manual testing. Let’s see how to compare source and target images and get the difference using ImageMagick with an example code.
Installation
Step-1: Download ImageMagick-6.8.9-8-Q16-x86-windows.zip from the following link http://ftp.icm.edu.pl/packages/ImageMagick/binaries/ and extract it wherever you want.
Step-2: Set E:SoftwaresImageMagick-6.8.9-8 in path environment variable
Maven Dependency
<dependency>
<groupId>org.im4java</groupId>
<artifactId>im4java</artifactId>
<version>1.4.0</version>
</dependency>
Code
import org.im4java.core.CompareCmd;
import org.im4java.core.IM4JavaException;
import org.im4java.core.IMOperation;
import org.im4java.process.StandardStream;
import java.io.IOException;
/**
* Created by Codoid Testing Services Company
*/
public class ImageComparisonExample {
public static void main(String args[]) throws InterruptedException, IOException, IM4JavaException {
CompareCmd compare = new CompareCmd();
compare.setErrorConsumer(StandardStream.STDERR);
IMOperation cmpOp = new IMOperation();
cmpOp.metric("mae");
cmpOp.addImage("image/image-1.png");
cmpOp.addImage("image/image-2.png");
cmpOp.addImage("image/image-diff.png");
compare.run(cmpOp);
}
}
You can also explore AppliTools Automated Visual Web & Mobile Testing to take your image comparsions to the next level.
by admin | Feb 27, 2017 | Automation Testing, Blog |
This article intends to touch upon some of the top challenges in test automation. We will also look at what approach we can take to conquer these challenges. We have been hearing and using the term ‘Automation’ for more than a decade now. Appreciating and listing the benefits of automation, especially Test automation should not be difficult for us.
Generating enormous ROI and value in terms of Test coverage, Peace of mind for developers and testers, reduced time to market, Eliminate wasteful and repetitive manual effort, Enables Agility, are all the immediate pluses we can recollect.

With great benefits, comes challenges/obstacles that need to be dealt with, to ensure the flow of value continues throughout and across the chain.
Communication
Probably the most unexpected challenge, yet placed first on the list!
Challenge:
Stakeholders have unrealistic notion and expectations about automating testing.
Approach:
Well, would you buy a home without planning on How many rooms, members and their requirements, Accessibility and availability of critical needs, Future needs, Hygiene, etc.? Certainly, the answer is NO. The same way, when a huge investment on Automation is made, it’s essential to talk to multiple and diverse people who will be directly or indirectly benefited.
For example; Review test cases, scripts and results with stakeholders (Developers, Architects, Business people, Project managers, Product managers, Business analysts, etc.). Helps in –
Finding issues, gaps early in the game
Team implementing or owning the Automation is abreast of the current changes/situation
Shared vision, Transparency across, all on same page
Infrastructure Needs and availability of a clean test environment
Challenge: Too many dependencies such as Database, browsers, applications, multiple Operating Systems may take days to be procured /setup /configured, which will shadow the benefits of automation.
Approach: By using Virtualization, and lately, cloud testing strategies – test environments can be created on demand and reused.
High upfront investment costs
Challenge: With the advent of Agile practices, it has become a mandate to automate Regression tests. The automation costs include Licensing, Infrastructure to support the automation framework, Operating costs of maintaining the hardware, updating the scripts to match the changing requirements, Training costs, etc.
Approach: There are free open source tools in the market such as Cucumber, JBehave and Serenity. Start cross-training team members. Focus your automation efforts to the selected few components that will ensure higher value.
Building the right framework and defining the Scope of automation
Challenge: Framework is what ties together all the logic that orchestrates the execution of test cases. Designing the right framework to meet your needs requires answering several questions such as – How to reduce effort in implementation and maintenance of the test scripts, What reporting features to include, look at the long term goals, how to minimize the effort when there is a change in testing strategy.
Approach: With baby steps, you can explore and implement the most important aspects that you want to automate. Remember – you cannot cover every component 100% for automation, instead choose the ones that will give higher value and focus your/team’s efforts on only those.
Need for Skilled resources
Challenge: Test automation being looked upon as just creating test scripts and putting them to run by themselves, involving just a tiny layer of testers, technical developers will not help us build scalable automation framework. Automation resources need to have a good blend of programming skills and automation tools know-how.
Approach: Partnering with a reliable Testing expertise provider who can collaborate with you to understand the short and long term goals to help formulate the testing automation framework.
Cross train resources internally. Include a mix of developers, architects, business analysts, testers into the team who will own automation.
by admin | Apr 22, 2017 | Automation Testing, Fixed, Blog |
In this blog post, you will learn how to read Excel file using JavaScript. exceljs – JavaScript Excel Library reads, manipulates and writes spreadsheet data and styles to XLSX and JSON.
We have used Apache POI, Fillo, JXL, and pyxll Excel Java & Python libraries for automation testing services. However, Reading and manipulating Excel file in JavaScript is very interesting.
Installation
You can install exceljs Excel Workbook Manager with the below npm install command.
`npm install exceljs`
Code
//Read a file
var workbook = new Excel.Workbook();
workbook.xlsx.readFile("data/Sample.xlsx").then(function () {
//Get sheet by Name
var worksheet=workbook.getWorksheet('Sheet1');
//Get Lastrow
var row = worksheet.lastRow
//Update a cell
row.getCell(1).value = 5;
row.commit();
//Save the workbook
return workbook.xlsx.writeFile("data/Sample.xlsx");
});
You can also read and write CSV file. Refer: Reading CSV and Writing CSV
by admin | Mar 10, 2016 | Automation Testing, Blog |
This is our very first article in Selenium, we hope it is helpful for Selenium users. Keep visiting Codoid blogs for more articles in the near future.
Using Custom JavaScript Mouse-event
//The below JavaScript code creates, initializes and dispatches mouse event to an object on fly.
String strJavaScript = "var element = arguments[0];"
+ "var mouseEventObj = document.createEvent('MouseEvents');"
+ "mouseEventObj.initEvent( 'mouseover', true, true );"
+ "element.dispatchEvent(mouseEventObj);";
//Then JavascriptExecutor class is used to execute the script to trigger the dispatched event.
((JavascriptExecutor) driver).executeScript(strJavaScript, element);
Using Device
//Getting mouse from driver object
Mouse mouse =((HasInputDevices)driver).getMouse();
//Invokes mouseMove method by passing element coordinates as argument
mouse.mouseMove(((Locatable)element).getCoordinates());
Using Advanced User Interactions API
Actions builder = new Actions(driver);
builder.moveToElement(element).perform();
//Note: (Preferable for Firefox and HTMLUnit drivers)