Posts

Localization,Internationalization Testing

Image
Learn what is Localization Testing and How to perform it: It is very common to find websites that are now available in multiple languages. Global brands have now recognized that the only way to connect and create value is by introducing their business to locals in the language that is truly local. This process of adapting a product to different language, region and locale is called localization. A localized product creates more business opportunities and caters for growth and expansion. However, many organizations make the mistake of adapting localization towards the end of the development process or just before the product launch. In order to localize a product it is very important to find out if it is internationalized. Confused? An internationalized Product/application design is the one that can accommodate localized content such as characters in non-western letters, double byte languages, ability for text to expand as in European languages and contract as in Asian lan

Page Object Model

Image
Design patterns A Design pattern is a generic solution to a common software design/architecture problem. Implementation of these design patterns leads to inclusion of best practices and best solution, evolved over the time by others while working with similar problems. Page Object Model in Selenium A Page Object Model is a design pattern that can be implemented using selenium webdriver. It essentially models the pages/screen of the application as objects called Page Objects, all the functions that can be performed in the specific page are encapsulated in the page object of that screen. In this way any change made in the UI will only affect that screens page object class thus abstracting the changes from the test classes. Advantages of using Page Object Model 1.Increases code reusability - code to work with events of a page is written only once and used in different test cases 2.Improves code maintainability - any UI change leads to updating the code in page obje

Page scrolling using Selenium

Scrolling a webpage is required in automation when the application requires scrolling down or up to display additional information e.g. most of the e-commerce sites display only 10-20 products at a time and then load more products as the user scrolls down. In this tutorial we'll take example of flipkart website and automate the scrolling of webpage in order to fetch more results. In automation first we will launch filpkart.com, write a search term and then scroll down to fetch more results corresponding to that search term. Automating page scrolling will make use of "scrollBy" method of javascript. For executing the javascript method we will use Javascript executor. The scrollBy method takes two parameters one each for horizontal and vertical scroll in terms of pixels. JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("scrollBy(0, 2500)"); Following test script automates flipkart's scroll down functionality to test display

Take screenshots for failed test

While doing manual testing we always have the machine in front of us to check what happened when the test case failed. In automation we rely on the assertion message that we print in case of failure. In addition to that we can also have screenshot of the browser in case of failure due to assertion or unavailability of any web element.  The code to take the screenshot make use of getScreenshotAs method of TakesScreenshot interface. Following code will take screenshot of the webpage opened by webDriver instance.  File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);  FileUtils.copyFile(scrFile, new File("D:\\testScreenShot.jpg"));  Now in order to take screenshot in case of test failure we will use AfterMethod annotation of TestNG. In the AfterMethod annotation we will use ITestResult interface's getStatus() method that returns the test result and in case of failure we can use the above commands to take screenshot. Code snippet to take screensh