Advanced Selenium IDE and Web Driver Telerik Software Academy Software Quality Assurance.

Slides:



Advertisements
Similar presentations
Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Pubman and Selenium tests. What is Selenium Selenium is a suite of Web application test automation tools for any browser on any operating system –Firefox,
The Web Warrior Guide to Web Design Technologies
1 Chapter 12 Working With Access 2000 on the Internet.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
Test Web applications using Selenium
Selenium – Testing Tool. What is Selenium? Selenium is a robust set of tools that supports rapid development of test automation for web-based applications.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Automation using Selenium Authored & Presented by : Chinmay Sathe & Amit Prabhu Cybage Software Pvt. Ltd.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
Philly.NET Hands-on Labs JAVASCRIPT SERIES. July 9: JavaScript Syntax Visual Studio ◦Projects ◦Editors ◦Debugging ◦Script blocks ◦Minification and bundling.
User Extensions, RC and Web Driver Anton Angelov QA Engineer SystemIntegrationTeam Telerik QA Academy Telerik QA Academy.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Selenium automated testing in Openbravo ERP Quality Assurance Webinar April 8th, 2010.
Val Kravets, Luis Sanchez, Allen Chung, Phillip Anderson, Leyla Norooz, Brian Ramnarian, Todd Watson.
Robot Framework – Basic Level. Date: Version:1.0 Page 1.
Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan.
Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan.
XPath XPath is used to navigate through elements and attributes in an XML document. XPath is a major element in W3C's XSLT standard - and XQuery and XPointer.
1 Test Automation For Web-Based Applications Selenium HP Web Test Tool Training Portnov Computer School.
Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan.
© 2012 LogiGear Corporation. All Rights Reserved Robot framework.
Testing Web applications. Selenium What is Selenium? Selenium is a suite of tools to automate web application testing across many platforms Tests run.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
ASP.NET.. ASP.NET Environment ASP.NET is Microsoft's programming framework that enables the development of Web applications and services. It is an easy.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Selenium Web Test Tool Training Discover The Automating Power Of Selenium Author : Girija Prasad Panda Alcatel-Lucent.
Testing Web Applications. Plan The presentation covers: Selenium framework Spring MVC Test framework HttpUnit framework.
Selenium and Selenium on Rails. Agenda  Overview of Selenium Simple Selenium Tests Selenium IDE  Overview of Selenium on Rails  Problems with Selenium.
Web Automation Testing With Selenium By Rajesh Kanade.
Pubman and Selenium tests. What is Selenium Selenium is a suite of Web application test automation tools for any browser on any operating system –Firefox,
Unleash the Power of jQuery Doncho Minkov Telerik Software Academy academy.telerik.com Senior Technical Trainer
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
SOAP-based Web Services Telerik Software Academy Software Quality Assurance.
WARSZAWQA#10.  Author: Michal Lamperski  Contact:  Find me on LinkedIn.
Lec 18 Web with Selenium 1 CSCE 747 Fall 2013 CSCE 747 Software Testing and Quality Assurance Lecture 16 Testing Web Applications 10/23/
Page 1 | | ©2009 Installation of Selenium IDE and RC Amit Maheshwari 20 th Sep’10.
Unit 13 –JQuery Basics Instructor: Brent Presley.
Selenium Date:06/10/2009. May 13, Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –
Selenium server By, Kartikeya Rastogi Mayur Sapre Mosheca. R
Test Automation Using Selenium Presented by: Shambo Ghosh Ankit Sachan Samapti Sinhamahapatra Akshay Kotawala.
Tata Consultancy Services1 WebDriver Basics Submitted By : Akhil K Gagan Deep Singh Naveenrajha H M Poornachandra Meduri Shubham Utsav Sunil Kumar G Vivek.
Robot Framework – Basic Level. Date: Version:1.0 Page 1.
Main Concepts of Web Testing Telerik Software Academy Software Quality Assurance.
Testing Your Alfresco Add-ons Michael Suzuki Software Engineer.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Testing Your Alfresco Add-ons Michael Suzuki Software Engineer.
Arklio Studija 2007 File: / / Page 1 Automated web application testing using Selenium
Introduction of Selenium Eli Lu 2016/10/13. Outline What is selenium ? Selenium Projects Selenium Sponsors Easy to use Useful Feature & Tools Useful Links.
Test Web applications using Selenium
Selenium HP Web Test Tool Training
The Zen of UI Test Automation
Selenium and Selenium on Rails
JRA2: Acceptance Testing senarious
CSCE 747 Software Testing and Quality Assurance
Onlineitguru Selenium is one of the most widely used open-source tool that is used for testing software or Automation. It is licensed under Apache License.
Selenium Tutorials Cheyat Training.
Getting Started With Solr
Presentation transcript:

Advanced Selenium IDE and Web Driver Telerik Software Academy Software Quality Assurance

 Anton Angelov Senior QA Licensing Team Blog: 2

 Selenium User Extensions  Selenium WebDriver  Element Locators  Custom Format  Page Object Model  Selenium Grid 3

 Selenium-Core is a JavaScript program  A set of JavaScript functions  Interprets and executes Selenese commands using the browser’s built-in JavaScript interpreter 5

 User extensions  External.js files containing JavaScript functions  Suitable for multiple use of JavaScript snippets  Easier to change  Function’s design pattern  "do" tells Selenium that this function can be called as a command 6 Selenium.prototype.doFunctionName = function(){...}

 User extensions  Function’s design pattern  custom locator – all locateElementByFoo methods on the PageBot prototype are added as locator-strategies 7 PageBot.prototype.locateElementByPartialId = function(text, inDocument) { return 'Z')][1]".replace(/Z/,text), inDocument); return 'Z')][1]".replace(/Z/,text), inDocument); }; }; Locates an element by a partial match on id

Started out around 2004 from Thoughtworks WebDriver merged with Selenium Selenium 1 used JavaScript to drive browsers Selenium 2 was released

 Selenium-RC "injected" JS functions into the browser when the browser was loaded and then used its JS to drive the AUT within the browser  Selenium-WebDriver makes direct calls to the browser using each browser’s native support for automation 10

 Positive points  Works with any browser that supports JavaScript  More life-like interaction with the browser  Not bound by the JavaScript sandbox  Large Communities  Support Many Program Languages 11

 Selenium WebDriver  A tool for automating web application testing  Developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded(AJAX)  Makes direct calls to the browser using each browser’s native support for automation the page itself being reloaded. 13

WebDriver Wire Protocol

 All implementations of WebDriver that communicate with the browser, or a Remote WebDriver server shall use a common wire protocol  The wire protocol defines a RESTful web service using JSON over HTTP  implemented in request/response pairs of "commands" and "responses“ Full Documentation: Full Documentation: ities ities 15

 POST Request  URL:  BODY: { "desiredCapabilities": { "desiredCapabilities": { "browserName": "chrome", "browserName": "chrome", "chrome.switches": [ ], "chrome.switches": [ ], "chromeOptions": { "chromeOptions": { "args": [ ], "args": [ ], "extensions": [ ] "extensions": [ ] }, }, "javascriptEnabled": true, "javascriptEnabled": true, "platform": "WINDOWS", "platform": "WINDOWS", "version": "" "version": "" }}

18 Create New Project in VS Install NuGet package manager and navigate to it Search for selenium and install the first item in the result list  Using NuGet packages

 Create an instance of a driver  Note: additional steps are required to use Chrome Driver, Opera Driver, Android Driver and iPhone Driver Chrome DriverOpera DriverAndroid DriveriPhone Driver Chrome DriverOpera DriverAndroid DriveriPhone Driver IWebDriver driverOne = new FirefoxDriver(); IWebDriver driverTwo = new InternetExlorerDriver(); 19 driver.Url = "  Navigate to page

 Choose and download browser driver you want to use for your tests (ex. Chrome) 20 using OpenQA.Selenium; usiOpenQA.Selenium.Chrome; namespace WebDriverDemo { class Program class Program { static void Main(string[] args) static void Main(string[] args) { IWebDriver driver = new IWebDriver driver = new driver.Url= " driver.Url= " } }} The IWebDriver interface can be find under OpenQA.Selenium namespace You have to tell the WebDriver API where this ChromeDriverServer is located

 Elements can be located by the same properties as in the IDE  By ID IWebElement element = driver.FindElement(By.Id("coolestWidgetEvah")); 22  By Class IList cheeses = driver.FindElements(By.ClassName("cheese"));  By Tag Name IWebElement frame = driver.FindElement(By.TagName("iframe"));

 By Name IWebElement cheese = driver.FindElement(By.Name("cheese")); 23  By Link Text  By CSS Selector  By XPath IWebElement cheese = driver.FindElement(By.LinkText("cheese")); IList inputs = driver.FindElements(By.XPath("//input")); IWebElement cheese = driver.FindElement(By.CssSelector("#food span.dairy.aged"));

 Chain of locators IWebElement cheese = this.driver. FindElement(By.ClassName(“firstElementTable")).FindElement(By.Id(“secondElement"));  XPath Support  Try to use native XPath support of browsers. On those that don’t have, WebDriver provided its own implementation Driver Tag and Attribute Native XPath Support Internet Explorer Driver Lower-casesNo Firefox Driver Case insensitive Yes Chrome Driver Case insensitive Yes

 What is XPath?  XPath is a syntax for defining parts of an XML document  XPath uses path expressions to navigate in XML documents  XPath contains a library of standard functions  XPath is a major element in XSLT  XPath is a W3C recommendation

 XPath Expressions Documentation: Harry Potter Learning XML Harry Potter Learning XML Driver Tag and Attribute bookstore/bookstore/book[last()] /bookstore/bookstore/book[last()-1] bookstore/book/bookstore/book[position()<3] /bookstore/book[1]/bookstore/book[price>35.00]/title //book/title | //book/price /bookstore/* //* //title | //price

 Location Path Expression Documentation: axisname::nodetest[predicate] Selects all ancestors (parent, grandparent, etc.) Selects all ancestors (parent, grandparent, etc.) descendant Selects all descendants (children, grandchildren, etc.) following-sibling Selects all siblings after the current node preceding-sibling Selects all siblings before the current node child Selects all children of the current node parent Selects the parent of the current node attribute Selects all attributes of the current node ancestor Selects all ancestors (parent, grandparent, etc.) Selects all ancestors (parent, grandparent, etc.) descendant Selects all descendants (children, grandchildren, etc.)

Hint: C# Documentation

30

 Explicit wait WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); IWebElement myDynamicElement = wait.Until ((d) => { return d.FindElement(By.Id("someDynamicElement")); }); 31 driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromS econds(10));  Implicit wait

 Implicit Wait – assert action executed in exact interval (Performance Testing)  Explicit Wait – use it for dynamic pages where you don’t cate about the execution time (Functional Testing)  Thread.Sleep() – don’t use it!

 Type Text into a field using Selenium WebDriver SendKeys() function // Find the text input element by its name IWebElement element = driver.FindElement(By.Name("search")); IWebElement element = driver.FindElement(By.Name("search")); // Enter something to search for element.SendKeys("telerik"); element.SendKeys("telerik"); 33

<select> Volvo Volvo Saab Saab Mercedes Mercedes Audi Audi </select> Hint: Install NuGet Package - Selenium.Support SelectElement selectElement = new SelectElement(driver.FindElement(By.XPath("/html/body/ select"))); selectElement.SelectByText("Saab");

What are you doing Saturday Overtime? 35

 WebDriver does not support the well-known commands of Selenium IDE like verifyTextPresent public static void AssertTextPresent(String value) { if (!driver.PageSource.Contains(value)) if (!driver.PageSource.Contains(value)) { throw new Exception(value + " is not present"); throw new Exception(value + " is not present"); }} 36 We can implement so

 There wasn’t any built-in method to assert text on a page  You can do something along the lines of static void Main(string[] args) { IWebDriver driver = new IWebDriver driver = new driver.Url= " driver.Url= " Assert.AreEqual("Google", driver.Title); Assert.AreEqual("Google", driver.Title);} 37

 The test results are limited by the Unit Testing Framework we use  ex. NUnit, MSTest, Gallio 38 Uning NUnit-Results

 Plugins for Selenium IDE  add WebDriver backed Selenium formatters  allows users to take advantage of WebDriver without having to modify their tests  US/firefox/addon/webdriver-backed-formatters/ US/firefox/addon/webdriver-backed-formatters/ US/firefox/addon/webdriver-backed-formatters/ 40

 You can add any format you like by writing JavaScript code  Open Options dialog ->"Options…" in the menu bar -> "Formats" tab  Create a new format by clicking "Add" button  There are 3 empty functions  parse  format  formatCommands 41

 The "parse" function is almost opposite of "format". This function parses the String and updates test case 42 function parse(testCase, source) { var doc = source; var doc = source; var commands = []; var commands = []; while (doc.length > 0) { while (doc.length > 0) { var line = /(.*)(\r\n|[\r\n])?/.exec(doc); var line = /(.*)(\r\n|[\r\n])?/.exec(doc); var array = line[1].split(/,/); var array = line[1].split(/,/); if (array.length >= 3) { if (array.length >= 3) { var command = new Command(); var command = new Command(); command.command = array[0]; command.target = array[1]; command.command = array[0]; command.target = array[1]; command.value = array[2]; commands.push(command); command.value = array[2]; commands.push(command); } doc = doc.substr(line[0].length); doc = doc.substr(line[0].length); } testCase.setCommands(commands); testCase.setCommands(commands);}

 The "formatCommands" function is similar to "format" function, but is used to copy part of the test case into the clipboard 43 function formatCommands(commands) { var result = ''; var result = ''; for (var i = 0; i < commands.length; i++) { for (var i = 0; i < commands.length; i++) { var command = commands[i]; var command = commands[i]; if (command.type == 'command') { if (command.type == 'command') { result += command.command + ',' + command.target + ',' + command.value + "\n"; result += command.command + ',' + command.target + ',' + command.value + "\n"; } } return result; return result;} 'ext.Driver.Navigate().GoToUrl("' + command.target.toString() + '");';

 The "format" function creates an array of commands contains command object (Command, Target, Value) 44 function format(testCase, name) { var result = ''; var result = ''; var commands = testCase.commands; var commands = testCase.commands; for (var i = 0; i < commands.length; i++) { for (var i = 0; i < commands.length; i++) { var command = commands[i]; var command = commands[i]; if (command.type == 'command') { if (command.type == 'command') { result += command.command + ',' + command.target + ',' + command.value + "\n"; result += command.command + ',' + command.target + ',' + command.value + "\n"; } } return result; return result;} return formatCommands(testCase.commands);

45

 The PageFactory class is an extension to the PageObject design pattern 46 private IWebDriver driver; [FindsBy(How = How.Id, Using = "SearchTerm")] private IWebElement Search; // How.Id = SearchTerm [FindsBy(How = How.Id, Using = "SearchButton")] private IWebElement Button; public FindUsersPage Do(string UserName) {Search.SendKeys(UserName);Button.Click(); PageFactory.InitElements(driver, (new FindUsersPage(this.driver))); return new FindUsersPage(driver); } FindUsersPage PageObject must be created FindUsersPage PageObject must be created The InitElements method of PageFactory initializes the elements of the PageObject Install Selenium WebDriver Support Classes package Install Selenium WebDriver Support Classes package

 PhantomJS is a headless WebKit scriptable with a JavaScript API  It has fast and native support for various web standards:  DOM handling, CSS selector, JSON, Canvas, and SVG 48 Download from

 Selenium-Grid allows you run your tests on different machines against different browsers in parallel 50 Hub Node Drivers

 The Selenium Server  Launches and kills browsers  Interprets and runs the Selenese commands passed from the test program  Acts as an HTTP proxy, intercepting and verifying HTTP messages passed between the browser and the AUT 51

 Selenium Server  Receives Selenium commands from the test program  Interprets them  Reports back to your program the results of running those tests  Bundles Selenium Core and automatically injects it into the browser  When the test program opens the browser 52

 Selenium Server can be downloaded from: 

 The Selenium RC server is simply a Java jar file (selenium-server.jar)  Doesn’t require any special installation  Just download the zip file and extract the server in the desired directory 54

 Running Selenium Server requires Java Development Kit (JDK) to be installed on your machine and included in the class path  e/downloads/index.html e/downloads/index.html e/downloads/index.html  Use CMD  Navigate to the directory where Selenium RC’s server is located and run the following from a command-line console:  java -jar selenium-server.jar 55

 Step 1: Start the hub java -jar selenium-server-standalone jar -role node -hub 56  Step 2: Start the nodes java -jar selenium-server-standalone jar -role hub  Using grid to run tests DesiredCapabilities capability = DesiredCapabilities.Firefox(); Driver = new RemoteWebDriver(new Uri(" capability); Hint: Open Grid Console from

58

59 Regression 1. Regression

60 System Level Testing 2. System Level Testing  Testing like the real user

61 Combinatorial Testing 3. Combinatorial Testing

62 Exact Requirements 4. Exact Requirements

63

Questions?

1.Create Automated Selenium WebDriver Test for  Log in in Use appropriate validations to create a good test  Go to “Settings” and fill in all the fields with information about yourself  Save changes and verity that updated information is shown on your profile page  Test if the validation of the input fields works properly. Think of an appropriate way to organize your validation tests  Think how to log test errors  Use Base test class with methods missing in WebDriver  Try To Use Page Object Model in your test 65

 C# Telerik Academy  csharpfundamentals.telerik.com csharpfundamentals.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com