by ABSoft Trainings | May 5, 2016 | Automation Framework, Selenium |
Are you using most recommended and fundamental SOLID principles in your automation? Why You Need To Use SOLID Principles? Like any development work, automation also needs to be planned, designed, developed, maintained and extended over time. Your automation code or automation framework is an application which is testing your actual application. That’s why SOLID principles are highly recommend for your automation to make it easy to understand, use, maintain and extend over time. When SOLID principles are not applied, your automation might become fragile, hard to maintain and hard to extend very soon. This is the first post in a series of posts that describe & apply the SOLID principles of object-oriented design and programming to web automation using Selenium & Java. Even if you are using different programming language like C#, Python or automation tool like HP UFT/QTP for automation, you should definitely consider applying SOLID principles to make your automation tester life easy. Please note that we will be discussing about applying SOLID principles to web automation using Selenium & Java. But, once you learn the concepts, you can easily apply them to any object-oriented development. In this post, we will be exploring what SOLID principles stands for. We will be having one post for each principle with real life examples from web automation using Selenium & Java. What Are The SOLID Principles? SOLID principles are the first five object-oriented design principles by Robert C. Martin, popularly known as Uncle Bob. SOLID is an acronym where:- S stands for Single Responsibility Principle (SRP) O stands for Open Closed Principle (OCP) L stands for Liskov Substitution Principle (LSP) I stands for Interface Segregation...
by ABSoft Trainings | Mar 15, 2015 | Selenium |
In this tutorial, we are going to cover following: What is Page Objects Framework? Why you should use Page Objects Framework? Selenium Automation Framework Architecture & Layers Automation & Page Objects Framework...
by ABSoft Trainings | Feb 12, 2015 | Selenium |
In this tutorial, we are going to cover following: Different JavaScript Popup Boxes – Alert, Confirm, Prompt How to handle them with Selenium Clicking OK/Cancel or Typing actions for JavaScript Popup...
by ABSoft Trainings | Jan 8, 2015 | Selenium |
In this tutorial, we are going to look at how to create and work with JUnit test suites. Using JUnit test suites, you can group and run multiple JUnit tests...
by ABSoft Trainings | Dec 28, 2014 | Selenium |
What is XPath? XPath locating strategies: XPath-Absolute XPath-Attributes XPath functions contains & starts-with XPath-Relative...
by ABSoft Trainings | Dec 22, 2014 | Selenium |
JAVA Code public class ExtractIntAndDouble { public static void main(String[] args) { //*************** Extracting int values ************************* String searchCountStr = “There are 280 search results”; // or String cartCountStr = “There are total 6 items in your cart”; int searchCount = Integer.parseInt(searchCountStr.replaceAll(“\\D”, “”)); System.out.println(searchCount); //*************** Extracting double values ************************* String totalPriceStr = “Your have paid £154.75 for this order”; // or String totalPriceStr = “Total Price: £154.75”; double totalPrice = Double.parseDouble(totalPriceStr.replaceAll(“[^0-9\\.]+”, “”)); System.out.println(totalPrice); } } In searchCountStr.replaceAll(“\\D”, “”), “\\D” is a regular expression to represent all non-digit characters and “” represents blank string. searchCountStr.replaceAll(“\\D”, “”) gives string with only digits like “280” by replacing all non-digit characters with blank string. In totalPriceStr.replaceAll(“[^0-9\\.]+”, “”), “[^0-9\\.]+” is a regular expression to represent all characters except digits 0-9 and dot character (.). Also, “” represents blank string. totalPriceStr.replaceAll(“[^0-9\\.]+”, “”) gives string with only double value like “154.75” by replacing all characters with blank string except digits 0-9 and dot character (.) . This is more effective than using split function (mentioned below) as we don’t need to worry about our int or double value position and currency symbols before price values String[] tempArray = searchCountStr.split(” “); int searchCount = Integer.parseInt(tempArray[2]); System.out.println(searchCount); The above code will work for string “There are 280 search results” but will not work for string “There are total 6 items in your cart”. This is because int value position changes in both...