The slide deck provides insight into the features of a Selenium-based test automation approach that allows rapid test development and maintenance, such as would be needed in an AGile project context.
2. Selenium
Selenium Testing
A t A g i l e S p e e d
Over the past few years the role of Selenium testing in project quality
assurance processes has changed. Its role has arguably tracked the
increasing dominance of online and mobile applications in the way in
which business reaches out to its customers and collaborators.
In addition to this trend, the use of agile development processes in
bringing such software applications to life, has become widespread.
This has had a profound effect on how the testing and quality
assurance processes proceed in order to deliver maximum business
value in such projects. Scoping testing to two- or three-week sprint
cycles and synchronizing with how the application parts are being
delivered, has brought quite some challenges.
And then we see the rise of Cloud and DevOps…
2
3. Selenium
Selenium Testing
A t A g i l e S p e e d
The role of manual testing has dramatically reduced in favour of
automated testing processes, processes that scale into continuous
build & deployment processes - DevOps activities.
How can a project effectively align its testing processes to its agile
development processes? Here we show a strategy that brings
Selenium-based testing of web applications into alignment with such
processes. The architecture described attempts to maximise the
following key metrics:
• Scalability
• Maintainability
• Accessibility
• Assertiveness
3
5. Selenium
Selenium Testing
A t A g i l e S p e e d
As an example, we showcase the test automation pattern by testing
the public web site (Lufthansa). It should be remarked here how this
site, being tested external to the Lufthansa organisation, reacts in the
following way to being driven by a test automation tool:
• If we move “too fast” through a testing workflow, then the site
detects that it is being driven by a “robot” and displays a generic
page content
• If we click on the various links on the main landing page, for
example, in the page footer, then a generic Captcha page content is
displayed. This effectively blocks test automation.
The main landing page of (Lufthansa), when browsing as a real user, is
shown as follows (as of September 2018)
5
6. Selenium 6
From the right-hand scroll bar, the overall content extends well beyond the current browser vertical dimension. Manually
scrolling to the end of the Strip Page, we see as follows:
7. Selenium 7
Compare this to what is seen when the site is driven by Selenium-based test automation code, the landing page looks as
following:
8. Selenium 8
Now we see a very different layout of elements – a “header” offering travel deals (requiring user interaction) as well as a
footer which requests the user to agree to cookie usage on the site (perhaps because of the recent European GDPR
regulations). Using Selenium to move to end of the Tab Strip, we see as follows:
9. Selenium 9
Now visible is a different “footer” apparently offering buttons to go fast-track to searching flights and price comparison
functionality offered on the site. Note that on this new footer there is a dismiss control, the ‘x’ at the top right of the panel.
If we should dismiss this panel, then we would see:
10. Selenium 10
It is only now we see the links to very important legal information to which the user of the site is agreeing to as part of a
(flight/hotel/car) booking - (Data Protection), (Terms & Conditions), (Passenger rights) and (Terms of use).
11. Selenium
Selenium Testing
P a g e O b j e c t G e n e r a t i o n
• The solution presented here uses a project XML
metadata file used to drive the generation of Page
Object code. The tool used to perform this generation
is (Se34) which can produce code in either C# or Java.
The Page Object classes thus generated are fully
finished in that they contain code to validate the items
specified in the XML metadata as well as methods to
perform appropriate operations on entities. For this
example, we use the C# option.
• A fragment of the metadata file is as shown following:
11
12. Selenium 12
This XML metadata file, is used to generate page-specific code to perform, among other things, the following:
• Validate all the specified page elements in an entity-specific way (“form”) given a specified locator style, e.g. “XPath”
• Perform actions such as Click, SelectByText etc.
• Perform a group of actions on a page defined by name, e.g. “EnterLoginCredentials”
• Allow the test code to address data shown in Tables in a natural object-oriented way
D . H a r r i s o n M a y , 2 0 1 9
D . H a r r i s o n M a y , 2 0 1 9
13. Selenium 13
As part of the generation process (optionally) property files are generated that contain the text to be validated, for each
page and each spoken language variant.
D . H a r r i s o n M a y , 2 0 1 9
14. Selenium 14
Above is a fragment of a unit test in Visual Studio/C# which performs some scrolling and basic validations. You can see that
Selenium data is absent as well as the actual text data being validated -> clean tests
D . H a r r i s o n M a y , 2 0 1 9
15. Selenium 15
Separation of Concerns
D . H a r r i s o n M a y , 2 0 1 9
UnitTestFrmwk
SeleniumFrmwk
Page Objects
Just code -
no data, no
tests
Validation Data
Just data -
no code, no
tests
Unit Tests
Only PO objects, no
validation data
App
16. Selenium
Selenium Testing
P a g e O b j e c t G e n e r a t i o n
• Clean architectural solution
• Tests can be structured to facilitate walk-throughs with
business actors
• Expanding the set of tests can be estimated with
confidence
• Tests can be designed within the context of agile
sprints (stories, story points) – maximise velocity
• Changes in Pages can be readily accommodated –
update metadata, generate (approach embraces early
days testing on a project)
• General technology lends itself to running the tests is
a cloud DevOps pipeline, e.g. Azure
16
17. Selenium
Selenium Testing
P a g e O b j e c t G e n e r a t i o n
• Scalability – straightforward process to develop new
tests. Easy to generate new Page Objects to expand
coverage or “maintain” existing ones
• Maintainability – Unit tests easy to maintain. Page
metadata easy to maintain. All code and generation
metadata file can be persisted in Git
• Accessibility – unit tests are “standard” so a developer
with “general” skill level can maintain. Page object
generation can be done by a general project person
• Assertiveness – the Page metadata allows for a range
of comparisons to be made- starts with, ends with,
regex, full etc.
17
18. Selenium
THANK YOU
h t t p s : / / w w w . d h a r r i s o n c h . c o m
/
D av i d H a r r i s o n
+ 4 1 ( 7 9 ) 1 7 6 ‐ 8 9 8 0
d h a r r i s o n _ c h @ y a h o o . c o . u k