bookstore/book

Report 1 Downloads 147 Views
Relational Databases and Web Integration Week 20 [email protected]

Tuesday, 18 August 2009

Scripting Web Sites As programmers, whenever we are performing repetitive tasks, we should be asking if we can program or script those tasks When testing a Web Application, we need to repeatably perform the same task recall from last week that all testing should be repeatable! implies we need some form of language to script web site interactions

Tuesday, 18 August 2009

Selenium Selenium is a popular scripting language for capturing and replaying web site interactions eg. Selenium IDE Firefox plugin Able to easily record browser sessions these may be saved, played back, etc. Combined with Firebug we have a powerful testing toolset

Tuesday, 18 August 2009

GUI Example We want tests to verify that a given page has a certain structure or elements present we could use Firebug to verify the presence of elements

Tuesday, 18 August 2009

GUI Example

Tuesday, 18 August 2009

GUI Example Tedious, error prone, repetitive so let’s script it! Say we need to verify that our client/sponsors image is present on the Google home page ie. a certain image element is present

Tuesday, 18 August 2009

GUI Example

Tuesday, 18 August 2009

Selenium Tests Can verify presence of HTML elements useful for ensuring test pre-conditions exist Can assert existence of HTML elements useful for performing tests Can interact with HTML elements ie. URLs, option lists, radio buttons, etc.

Tuesday, 18 August 2009

Selenium Tests Can also model form input Firefox plugin has an events recorder so to generate a Selenium test, simply: set IDE to record actually perform your event sequence finally, edit resulting test and insert asserts

Tuesday, 18 August 2009

Selenium Tests Can use Selenium tests to ensure that Web Applications have: an expected page structure an expected navigational structure an expected inter-page communication structure So we can test Web Application GUI’s and their Webflow!

Tuesday, 18 August 2009

XPath XPath is a syntax for defining parts of an XML/xHTML document XPath uses path expressions to navigate XML documents

Tuesday, 18 August 2009

XPath Expressions XPath uses path expressions to select nodes or node-sets in an XML/xHTML document These path expressions look very much like the expressions you see when you work with a traditional computer file system ie. we view the XML/xHTML document as having a tree structure

Tuesday, 18 August 2009

XPath Nodes Root Node

Parent

Tuesday, 18 August 2009

Attribute Harry Potter J K. Rowling Node 2005 Child <price>29.99

Node

XPath: Selecting Nodes Expression

Description

nodename

Selects all child nodes of the named node

/

Selects from the root node

//

Selects nodes from the current node that match the selection - no matter where they are

.

Selects the current node

..

Selects the parent of the current node

@

Selects attributes

Tuesday, 18 August 2009

XPath: Selecting Nodes Harry Potter J K. Rowling 2005 <price>29.99

/bookstore bookstore/book //@lang Tuesday, 18 August 2009

XPath: Predicates Predicates are used to find a specific node or a node that contains a specific value Predicates are always embedded in square brackets

Tuesday, 18 August 2009

XPath: Predicates Harry Potter J K. Rowling 2005 <price>29.99

/bookstore/book[1] //title[@lang] //title[@lang='eng'] /bookstore/book[price 6.99

or, and

price >= 6.99 and price
Recommend Documents