Web Testing With Selenium Presented By Quontra Solutions

Information about Web Testing With Selenium Presented By Quontra Solutions

Published on August 6, 2014

Author: quontra123

Source: authorstream.com

Content

PowerPoint Presentation: Locators In Selenium Presented By Quontra Solutions Online Training on all IT Courses For Free Demo Call Us:+1(404)-900-9988 Email: [email protected] PowerPoint Presentation: What is Selenium? Selenium Portable software testing framework for web applications Selenium IDE Selenium Client Drivers Selenium RC Selenium Grid 2 PowerPoint Presentation: Why use Selenium? Why automated testing? Speed Repeatability Reliability Cost Requalification (security patches) Verisimilitude (vs HTMLUnit) 3 PowerPoint Presentation: Selenium Locators id – fastest method name link dom css xpath – slowest method 4 PowerPoint Presentation:  Identifier Works with the ID and name attributes of your html tags. Let’s consider the following example: <html> <body> <form id=”login”> <input name=”username” type=”text”/> <input name=”password” type=”password”/> <input name=”submit” type=”submit” value=”Continue!”/> </form> </body> </html> Valid locators for this snippet are : identifier=login identifier=username submit PowerPoint Presentation: Id The Id strategy looks for an element in the page having an id attribute corresponding to the specified pattern. <label id=” my_id ” /> will be matched by a locator like id= my_id or just my_id  Name Like the Id strategy, but on the name attribute. You can also specify a filter to refine your locator. Currently, there are two filter types : Value : matches elements with a name attribute and where the value follows a pattern. The following example illustrates the interest of filters : <html>   <body>     <div id=”pancakes”>       <button type=”button” name=”pancake” value=”Blueberry”>Blueberry</button> PowerPoint Presentation:  <button type=”button” name=”pancake” value=”Banana”>Banana</button>      <button type=” button”name =” pancake”value =”Strawberry”>Strawberry</button>    </div>  </body> </html> Link This strategy is intended to select links only and selects the anchor element containing the specified text: link=The text of the link DOM The DOM strategy works by locating elements that matches the javascript expression refering to an element in the DOM of the page. dom = document.div ['pancakes'].button[0] document.div [0].button[2] dom =function foo() { return document.getElementById (“pancakes”); }; foo(); PowerPoint Presentation: XPath While DOM is the recognized standard for navigation through an HTML element tree, XPath is the standard navigation tool for XML; and an HTML document is also an XML document ( xHTML ). XPath is used everywhere where there is XML. Valid XPath locators can be: xpath =//button[@value="Blueberry"]: matches the Blueberry button //div[@id="pancakes"]/button[0]: same thing CSS The CSS locator strategy uses CSS selectors to find the elements in the page. Selenium supports CSS 1 through 3 selectors syntax excepted CSS3 namespaces PowerPoint Presentation: Selenium RC 9 PowerPoint Presentation: Selenium Challenges Web app latency can cause tests to fail waiting on page events Tests tend to lock in web pages, slowing iterative development Selenium core is JavaScript based Not all browsers interpret the same way Can't perform cross-domain testing Testing secure connections is tricky, and often browser specific Execution is slow (compared to most unit tests) Formatting problems are untested 10 PowerPoint Presentation: Handling Event Latency Example: An event is triggered on the page when a user enters invalid data. public static void waitForPageValidation(DefaultSelenium selenium, String id) throws InterruptedException { for (int second = 0;; second++) { if (second >= 5) { fail("timeout waiting for event); } try { if (selenium.isVisible(id)) { break; } } catch (Exception e) {} Thread.sleep(1000); } } 06/21/11 11 PowerPoint Presentation: Managing Change Separate page content used in tests from actual test logic. Most frequently used content: Page titles Field locators (ids, names) 12 PowerPoint Presentation: Selenium 13 Advantages Disadvantages No Selenium RC installation No final version released (summer 2011) Cross-domain testing capabilities Limited backwards compatibility Object-oriented API Smaller number of supported browsers Mobile browser testing PowerPoint Presentation: Speeding Up Selenium Avoid xpath; have id attributes for all tested fields Reuse browser sessions (although this can cause subsequent tests to fail if the session fails) Test local builds to reduce network latency Avoid using multi-page test flows for atomic tests Use parameterized tests to test multiple browsers at once Parallelize tests to run multiple test classes at once Use cloud-based testing services 14 PowerPoint Presentation: ThankYou

Related presentations


Other presentations created by quontra123