3. We test what is on the browser The browser always gets HTML, javascript We don't need to worry about the server technology! Server or Browser?
4. Locating elements Document Object Model XPath Simulating events From within the browser From outside the browser Test building blocks
5. HTML Pages -> represented in Javascript as a live window.documentobject Anything can be accessed through DOM document.getElementsById("id") document.forms[2].elements["login"] document.images[23].src document.links[5].href DOM: Document Object Model
6. XPaths are used to access structured XML data <person> <name>Ram</name> </person> //person[0]/name XPaths
7. HTML is not data, it is presentation + data <div> <span class="labels">Name: </span> <span>Ram</span> </div> /html/body/div/span[2] Semantic information now has to be ADDED to html id cssclass (more for presentation) Not the best solution XPaths (contd)
8. Window1 Frame1 Frame2 IFrame1 XPath does not traverse Frames and Iframes. User has to identify the containing Frame or Iframe before using Xpath Xpath is not consistent across browsers Xpath is slow More problems:
9. DOM properties and methods are browser dependent Need good wrapper functions To access DOM, need to go inside the browser Browser plugins Proxy based approach But, if accessible, DOM is more powerful than XPath DOM
10. Can monitor page load state and AJAX state No need for waits Can create elegant functions in javascript to normalize browser differences //table[@id='listing']/tbody/tr[4]/td[4]/input Vs _textbox("q", _near(_cell("Python Cookbook"))) DOM Advantages
11. Outside Will be “real” simulation of events (OS level) May need browser in focus The correct way, if easily possible Write drivers for every browser type Maintenance problem Browser quirks Inside Proxy based approach Easy, but events are simulated at browser level Browser events allow parallel execution Browser extensions Maintenance Inside or Outside the browser?
12. Tests should run on any browser Steps should wait automatically for page load, AJAX Element identification should be stable Record/identify elements automatically on any browser Reduce playback time by running in parallel Handle complex UIs without the necessity to add ids Be simple to learn, scale and maintain What we should look for in Tools
13. Use a proxy Inject smart javascript Can handle any browser Can wait for page load/AJAX Can record on any browser Simulate events inside the browser Allows parallel playback Easy to maintain – small code base Minimal dependency on browser/OS architectures Simplest possible approach
14. Object identification and event simulation are nearly solved problems Tests should reflect intent rather than implementation of UI. Login as “testuser” with password “secret” Vs _click(_button("Logout")); _setValue(_textbox("user"), "test"); _setValue(_password("password"), "secret"); _click(_submit("Login")); Going beyond
15. V Narayan Raman narayan@tytosoftware.com http://sahi.co.in/ Q&A