32
a LEAPWORK whitepaper Everything you need to know about automating web-based tests and processes GUIDE TO WEB AUTOMATION

GUIDE TO WEB AUTOMATION

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

a LEAPWORK whitepaper

Everything you need to know about automating web-based tests and processes

GUIDE TO WEB AUTOMATION

Guide to web automation

What is web automation?

What is Selenium browser automation?

The pros and cons of Selenium

How to build web automation

Web automation with Selenium-powered building blocks

Common web-based operations and functionalities to automate

Web automation use cases

Automating ticket creation and service desk requests

Automation of industry-specific back-office systems

E-commerce automation

Automating CRM workflows

Automating intranets and extranets

Executing web automation

How to set up hosted environments for automated web testing

Parallelization of Web Automation

Execution Agents – on local, remote, or virtual machines

Selenium Grid

Conclusion

4

4

5

7

8

8

10

11

11

11

12

12

12

13

13

15

15

15

17

Get started with test automation strategy in 8 steps

1. Scope

2. Approach

PROCESS

TECHNOLOGY

ROLES

3. Risk analysis

4. Environment and data

5. Execution plan

6. Release control

7. Failure analysis

8. Review and feedback

Selenium WebDriver vs. LEAPWORK

Usability and Adoption

Documentation and Governance

Applications Supported

Test Execution and Integrations

18

19

19

19

19

20

21

22

23

24

25

25

26

27

28

29

30

Guide to web automation

4

GUIDE TO WEB AUTOMATIONCustomer interaction is increasingly happening online. This means that websites and

web applications are crucial to generating revenue. It also means that several front

and back-office applications are migrated from desktops to web-based interfaces or

the cloud. This transformation creates a technology dependency. To lower costs and

mitigate risk, businesses face an urgent need for automating web-based tests and

processes, in an easy, yet reliable way.

In this guide, you will learn:

What is web automation?Web automation is the process of automatically performing actions on a web browser

or web application, in order to achieve speed and efficiency.

Think of all the clicking and typing you do at your desk everyday that involve

websites and web-based applications. All these actions can be automated with web

automation. Examples of tasks include:

• Filling out forms and fields

• Scraping content from a web page

• Extracting and transferring data between applications

• Clicking buttons and elements

Every day, in businesses of all sizes, there are scenarios where automating tasks like

these would come in handy. For example:

• Importing contacts into a CRM system from a third-party service

• Testing the user experience and order handling of an online shop

• Integrating a web-based ERP-system with a document management platform

in the cloud

Guide to web automation

5

WHAT IS SELENIUM BROWSER AUTOMATION?When talking about web automation, there is no way around Selenium, the world’s

most popular open-source framework for automating browsers.

The Selenium tool suite consists of Selenium WebDriver, an automation tool built for

automating in the browser, Selenium IDE, a record and playback tool, and Selenium

Grid, a parallel testing tool. In the following, we’ll focus on Selenium WebDriver.

All components of the Selenium suite are open-source tools for automation of websites

and web applications. Selenium cannot be used for other types of applications, such

as desktop.

WebDriver is an API that can automate any action that takes place in a web browser.

It drives browser actions natively, meaning that it interacts with browser elements,

like clicking on buttons, typing text in fields, etc., like a real user would.

Selenium WebDriver is operated by writing code in a programming language, such

as C#, JavaScript, PHP or Python.

Creating a Selenium script is a 7-step process as described in SauceLabs’ Selenium

introduction:

Guide to web automation

6

Below is an example of what a Selenium test script can look like. In this case, the

WebDriver is instructed to:

1. Open a Chrome browser

2. Navigate to the web page amazon.com

3. Input the term “Lego” in a search field

4. Wait for the page to load results

5. Click on one of the items in the search results, and then

6. Conclude the test case by verifying the presence of a specified image

As illustrated by this case, a considerable amount of programming proficiency is

required to understand, let alone create, a relatively simple script.

Guide to web automation

7

THE PROS AND CONS OF SELENIUMSelenium is one of the most widely used frameworks for web automation, with good

reason. The software’s strengths include:

• Open source and free

• Highly extensible

• Can run cases across different browsers

• Supports various operating systems

• Supports mobile devices

• Can execute cases while the browser is minimized

• Can execute cases in parallel

Selenium WebDriver does, however, have its limitations, when used as a stand-alone

tool. These are listed below.

By using a fully-featured automation tool which has incorporated the WebDriver in its

technology, like the LEAPWORK Automation Platform, you can enjoy the advantages

of WebDriver without having to worry about the tool’s limitations:

Guide to web automation

8

HOW TO BUILD WEB AUTOMATIONWeb-based tasks and processes can be broken down into three overall types of

actions:

• Operating browsers to navigate the web

• Interacting with web elements, both static and dynamic

• Inputting/outputting data, text, and numbers

In theory, that’s all you need to know to start building automated processes involving

websites and web applications.

Web automation with Selenium-powered building blocksImagine if each action and operation listed above was a building block that you could

connect to make up visual workflows representing web-based processes. That’s the

idea behind LEAPWORK’s Selenium-powered web automation blocks.

The example below automates the following process: Search for an item (“star wars

lego”) in an online shop (amazon.com) and then compare the number of search

results with a specified value (2500).

Guide to web automation

9

The automation flow outlined in this example is created by connecting just seven

commands, or building blocks:

This approach of using visual building blocks to design processes enables automation

of practically any web application and websites in any of the common browsers:

Google Chrome, Mozilla Firefox, Microsoft Edge, and Internet Explorer.

Guide to web automation

10

Common web-based operations and functionalities to automateAll web-based tasks and processes involve operating browsers, interacting with web

elements, and inputting or outputting data. Examples include: typing credentials

into an authentication form, dragging and dropping elements on a web page and

uploading a file to a web application.

Some operations are more challenging than others to automate, meaning they

require a few more configurations to make a robot perform the operation correctly.

For example, with the LEAPWORK automation blocks, to find a specific element

on a web page, you just need a simple “Find Web Element” block, but to verify an

‘infinite scroll’ functionality on a web page you need to do a minor configuration in

the same block and then customize the strategy by removing the unique references

to the captured element and making selection criteria generic.

However, you can still instruct a LEAPWORK robot to perform even this slightly more

complex example without having to write a single line of code.

Now that we have covered the ‘bricks’ that make up web automation, let’s take a

closer look at how web automation is used across organizations to solve various

challenges.

Guide to web automation

11

Selenium Automation?

WEB AUTOMATION USE CASESWeb automation is applicable to processes involving any website and web application,

both external and internal. Below are some real-life examples of how organizations

are benefiting from web automation.

Automating ticket creation and service desk requestsAt a major utility company managing critical infrastructure for energy and gas, all

service desk requests are managed with ServiceNow, a web-based business process

platform.

ServiceNow is a great example of an application that can be automated with the

codeless Selenium-based automation approach outlined above.

Utilizing web automation, the IT process team at the utility company could automate

the testing of business flows going across functions and departments involving

multiple applications, including ServiceNow. This has allowed them to significantly

reduce the time spent on testing in relation to system upgrades. This time was instead

allocated to business-critical tasks, such as customer support.

More frequent system upgrades + Earlier fixing of system bugs + Security risks

reduced = Better Customer Experience.

Automation of industry-specific back-office systemsBack-office functions are increasingly being handled with web-based applications

– even industry-specific ones, such as Policy Management Systems (PMS) in the

insurance sector and Transport Management Systems (TMS) in logistics companies.

From an automation perspective, this move to web-based technologies simplifies

things: Any application that can be operated using a web browser, can be automated

with the approach described in this guide.

For example, an insurance company moved from quarterly to monthly releases of

their policy management system, by automating the testing of the system based on

the web application Pega.

Guide to web automation

12

Another example: a global logistics company automated their web-based online

booking system which integrates with their TMS, reducing weeks of workload to the

few clicks required to instruct robots to perform repetitive tasks.

E-commerce automationE-commerce plays a key role in selling and purchasing products and services today:

Digital and mobile storefronts, electronic transfer of funds, web-based inventory

systems, and online marketing are just a few of the different aspects of e-commerce.

Automating front- and back-end processes for monitoring and testing purposes can

help enhance the robustness and quality of an e-commerce channel. This involves:

• Ensuring the functionality of an online shop from an end-user perspective

• Continuous monitoring of the operational status across channels

Automating CRM workflowsCRM systems have great automation potential; they are used for processes that go

across departments and functions, they are often web-based, and the tasks involved

are often repetitive.

Salesforce, for example, is a top tier CRM solution for enterprises and organizations.

It offers cloud services for managing sales, marketing, help desk requests and more.

It’s highly customizable and can be configured and extended to fit almost any

requirement. The size and complexity of Salesforce means that many repeatable

tasks are performed manually by sales reps, marketeers and managers over and over

every day.

Automating intranets and extranetsWeb automation is not only for public systems. For example, a global manufacturer

of medical devices automated a SharePoint-based service portal monitoring devices

and systems at thousands of hospitals worldwide.

Guide to web automation

13

EXECUTING WEB AUTOMATIONWhen it comes to executing web automation flows, there are two major concepts

you need to know about:

• Hosted environments: This is about executing automation flows across devices

and systems using cloud-based services.

• Parallelization: This means running automation flows on several machines at

once.

How to set up hosted environments for automated web testingTo deliver a great end-user experience, web applications and websites must work

across multiple browsers, browser versions, operating systems, and devices, including

mobile.

With all the possible combinations, there is a large number of usage scenarios to

be tested. One provider of hosted environments for automated web testing, Sauce

Labs, at one point identified more than 2,000 devices and more than 800 browser-OS

combinations – and those were just the most commonly used.

From a testing perspective, a question presents itself: Is it necessary for your

organization to host all the possible combinations of browsers, operating systems,

and devices in your own infrastructure to support automated web testing? This

would come with additional costs and a massive administrative burden negatively

impacting the business case for test automation.

Fortunately, you can outsource the hosting of test environments to vendors such as

BrowserStack and Sauce Labs.

What follows is a walk-through of how to use hosted environments for web automation.

Besides access to a provider of hosted environments, setup only requires a few

things: A suite of automated test cases ready to be executed, and a service running

the test cases, called the Controller.

Guide to web automation

14

With this setup, a test team does not have to worry about preparing and maintaining

the machines and devices on which the test cases are executed. For example, it is

not necessary to purchase, maintain, and charge a bunch of different mobile devices.

Guide to web automation

15

PARALLELIZATION OF WEB AUTOMATIONBesides using environments hosted by cloud-based providers as described above,

there are other ways to parallelize web automation, including execution agents and

Selenium Grid.

Execution Agents – on local, remote, or virtual machinesAn execution agent is a piece of software that is installed on every machine where

automation cases are to run. Agents allow for a great deal of flexibility, as they can

execute automation commands on both local, remote, and virtual machines. Agents

can be installed in different and separate environments, including cloud servers,

allowing for collaboration across teams and even across organizations, for example if

you work with an automation partner.

Selenium GridSelenium Grid is a server for setting up different environments in which automation

cases are executed. It is based on a Hub-Node concept and can be set up in your

own infrastructure.

The Hub is the central machine running the automation cases, and the Nodes

are different machines on which the actual browser automation takes place. The

advantage of Selenium Grid is the ability to run multiple cases in parallel across

different browsers, operating systems, and machines.

Guide to web automation

16

The different options for parallelizing web automation with LEAPWORK are illustrated

below. The LEAPWORK Controller is the test runner service, and LEAPWORK Studio

is where users design their automated test cases. Learn more about the different

deployment options with LEAPWORK.

The two major cloud-based providers of hosted environments, Sauce Labs and

BrowserStack, are both supported by the LEAPWORK Automation Platform. This

makes it incredibly easy to set up hosted environments for automated web testing.

Guide to web automation

17

CONCLUSIONWeb automation is a critical part of reducing risk and ensuring efficiency in connection

with web applications.

Selenium is a popular tool for this, but it can hinder efficiency, due to the level of

coding it requires to use.

LEAPWORK uses Selenium under the hood, but hides unnecessary complexity and

lets you automate with simple building blocks, that give you an optimal overview of

your processes.

Next is an overview of how LEAPWORK compares to Selenium WebDriver.

Guide to web automation

18

GET STARTED WITH TEST AUTOMATION STRATEGY

Guide to web automation

19

GET STARTED WITH TEST AUTOMATION STRATEGY IN 8 STEPS

1. ScopeThe first step to consider when introducing automation into your testing is the scope.

This includes outlining timelines and milestones for each sprint in the project, as well

as defining which test cases should be automated and which should be kept manual.

It’s important that all team members (product owners, developers, testers, etc) are on

board with this scope, and that each know their responsibilities for the different parts

of the project (we’ll go into further detail with this in the next step).

2. ApproachWhen choosing a test automation approach, there are three areas to consider:

process, technology, and roles.

PROCESSWhen building your automated testing suite, it’s important to have a well-defined

and structured process. Make sure to cover the following in your plan:

• When during the sprint should automated test cases be developed?

• When are features ready for automated testing?

• Which features are tested manually?

• Who takes care of maintenance?

• How do we analyze results?

TECHNOLOGYBefore you start, you’ll also need to identify which applications you need to automate,

and what technologies these are based on. This will determine which test automation

tool you should be using.

In most cases, testing will involve several application types: web-based, desktop-

based, mobile apps, SAP/Dynamics/Oracle, etc., therefore it’s important to have a

tool that can handle all your automation requirements.

Guide to web automation

20

Many start out automating with a free, open-source tool, such as Selenium, but then

run into problems when they find out that it only covers some of their testing needs

(Selenium only works with web-applications).

In addition, developers and testers often end up spending a substantial amount of

time on writing automation scripts as well as maintaining all those scripts down the

line.

ROLESNext, you need to define the roles for automation in your team. Testing may not be

the only thing you’re automating, in which case keeping an overview of who does

what is essential.

Examples of roles and responsibilities include:

• Automation lead: Responsible for coordinating and managing all activities

regarding automation in the project.

• Test case designer/reviewer: Similar to code reviews among software

developers, it’s important to establish a review process for automated test

cases. This means that a tester will typically have at least two roles: test case

designer and test case reviewer.

Over time, your testing suite will inevitably grow as your software is developed,

meaning more and more time will go towards maintenance.

What’s more, it’ll become all the more important that there are clear roles defined

for handling this suite (the more complex it gets, the higher the risk of breaking

automation flows).

In this respect, it’s highly beneficial to use a testing tool that first of all lets you keep

a clear overview of your testing suite. A visual, no-code testing tool, as opposed to a

scripted one, will make this a lot easier.

Secondly, it’s beneficial to have a tool that allows you to administer roles and access

to automation flows and suites.

Guide to web automation

21

3. RISK ANALYSISIt can be a difficult and time-consuming task to try to foresee everything that can go

wrong, to estimate the cost of this, and to find a way to mitigate or avoid that risk.

Nonetheless, it’s important to at least consider these things.

Depending on your business’ size and the complexity and importance of your business

processes, you can perform this risk analysis with the simple approach outlined in the

example below, or you can move into a more extensive process of risk scenarios, cost

calculations and mitigation planning.

The analysis below is created by listing the identifiable risks qualified with these

details:

• Description and relevant metadata

• Severity: What will happen if the risk becomes reality?How hard will it hit the

project?

• Probability: What is the likeliness that it happens?

• Mitigation: What can be done to minimize the risk?

• Cost estimate: What is the cost of mitigating the risk –what is the cost of not

doing it?

Guide to web automation

22

4. ENVIRONMENT AND DATAThe next things to consider in your test automation strategy are testing environments

and data.

Organizations with a software department will typically have a more or less well-

defined method for how software is released to production. This process usually

includes one or more test environments.

Some release pipelines are mature and well-defined (i.e. a DevOps pipeline) and the

work towards fast releases has either already begun or been deemed not relevant.

In any case, it is important to evaluate the current state of your test environments.

Test automation is a “deterministic game”; known inputs will produce predictable

outputs. This means that stable and predictable test environments are a prerequisite

for successful test automation.

In relation to this, you should also consider the data that is part of the tests:

• Where to store test data?

• Will it work to use a copy of production data?

• Can production data be masked?

• Should the test cases clean up data on their own after use?

Guide to web automation

23

5. EXECUTION PLANAt this point you’ll already have considered the scope of your project in terms of

timelines and responsibilities. This next step is about turning those elements into an

actionable plan.

An execution plan should outline the day-to-day tasks and procedures related to

your automated testing.

Before any automated test cases are added to the automation suite, it’s best practice

to run and verify the tests multiple times to ensure that they run as expected. False

failures are time-consuming, so it’s essential that test cases are robust and reliable.

It may be a good idea to create a procedure for making test cases resistant to changes

in the system being automated.

This procedure will of course depend on the application in question, but it should

cover how test cases recognize and interact with elements in the application under

test. Execution of test cases should be handled either by the pipeline orchestrator

(Jenkins, TFS, Bamboo, TeamCity, etc.) or by a scheduling tool.

This means that tests will run either as part of a build/deployment event or on a

known time during the day. Also consider selecting a setup that allows for parallel

execution of the test cases to get the feedback from the tests faster back to the

development team.

Remember, you can never test too much, and the combination of test automation,

reliable test cases, and scheduled/controlled execution will inevitably have a positive

effect.

Guide to web automation

24

6. RELEASE CONTROLIn any release pipeline, regardless of its complexity and maturity, there is a point at

which a team needs to decide whether to release a build or not. Parts of this decision-

making can be automated, while other parts still require human, critical thinking.

In other words, the final decision regarding release should ideally be based on a

combination of algorithm results and manual inspection.

In any case, regression test automation results will play a critical role in this decision.

But it’s up to you to decide if you only want to allow releases if all tests pass, or if you

want to have the lead tester approve the result.

After a complete run of your regression tests, you should consider including the

application logs as part of the release decision. If the regression tests have good

application coverage, then any errors not related to the UI should reveal themselves

in the log files.

Guide to web automation

25

7. FAILURE ANALYSISHaving a plan for how to analyze failing test cases and the actions required to take

afterwards is a critical—yet sometimes neglected—part of test automation strategy.

The time it takes from the point where a tester is notified of a failing test case until

the fix is described, understood, and accepted in the development backlog is usually

much longer than teams anticipate. As a consequence, release cycles risk being

delayed, and the agile team becomes less agile.

Having a well-defined process for this can save a lot of time and frustration throughout

the release cycle. A good place to start is to outline how different errors should be

handled and by whom. For example:

• Environment issues → Raise a ticket with the DevOps team

• A bug in the application under test → Flag a bug for Development

• A bug in the automation scripts → Create a task for the test team

8. REVIEW AND FEEDBACKFinally, once you’ve drafted your test automation strategy, you’ll want to make sure

that it is reviewed and approved by all members of the involved development team.

From here, try to work on enforcing a culture for continuous learning and improvement,

where you include and embrace feedback from stakeholders, peers, and all team

members working with automation and adjust the strategy where needed.

What next?

Once you have a relatively good idea of how you want to approach your automated

testing, and you’ve made an effort to plan the automation journey that lies ahead of

you, the next step might be to find the right test automation tool.

Next is a comparison between code-based Selenium WebDriver and no-code web

automation platform LEAPWORK.

Guide to web automation

26

SELENIUM WEBDRIVER VS. LEAPWORK

Guide to web automation

27

Using Selenium

WebDriver with hand-

written code

Using LEAPWORK,

which uses Selenium

under the hood

Programming needed Can only be used by programmers, who get low-level access to browser behavior and actions through using any programming language (C#, Java, Python, PHP, etc).

Can do the exact same thing with easy-to-use building blocks, and without having to read or write a single line of code. Perfect for non-technical users – or anyone who just doesn’t want to spend time on programming.

Enterprise support No enterprise support exists, the Selenium project is run by the open source community.

On-demand live support from automation specialists.

Data-driven

automation

Data-driven automation requires sophisticated programming and separate management and storage of data assets.

Data-driven automation is included out of the box. It is done by visually connecting data sources such as databases, API endpoints and Excel files with other building blocks.

Finding web elements Uses highly complex CSS or XPath “selectors”, which require deep technical knowledge.

Point and click to capture any web element. Smart algorithms then automatically find the best way to locate it again in the future.

Road-map influence Although Selenium is open source, the only way to influence the road map is to actively participate in the community programming effort for Selenium itself.

All enterprise users have direct access to live chat and product team representatives. About a third of all product development is a result of this dialogue.

USABILITY AND ADOPTION

Guide to web automation

28

Training materials A good ecosystem and lots of code samples exist on the internet for professional programmers to use. Some tutorials on YouTube and many professional courses exist but require technical skills.

All users have access to a comprehensive learning center with many hours of free videos. Enterprise users can participate in a professional certification program.

Speed of adoption Typically takes 3-6 months for an initial project, then another 6-12 months for framework programming.

Most users are able to adopt within 3-5 days, using a structured learning and on-boarding program.

Selenium WebDriver LEAPWORK

Reporting and

dashboards

No reporting or dashboard solution is included. Programmers can custom-build their own reporting framework (typically takes 3-6 months).

Reporting and dashboards are included out of the box. Results can also be pushed to other tools such as JIRA.

Automatic video

recording

Video recording is not included and is very difficult to achieve, even with a custom-built solution. Programmers are typically limited to saving screenshots with no retention policy.

Everything is automatically recorded on video, and a retention policy can ensure old videos are automatically deleted.

DOCUMENTATION AND GOVERNANCE

Guide to web automation

29

Object repository and

version history

An object repository is not included, but programmers can custom-build their own and decide on implementing code patterns such as Page Object Model. Version history can be achieved using source control systems such as Git, which most non-technical users find impossible to navigate.

All assets such as web element locators and flows are structured and stored in an encrypted database with built-in version history.

Access control No access control is included and is difficult to achieve with a custom-built solution.

Access control, both locally in the encrypted database and through Active Directory is included.

Tamper-proof audit

trails

No audit trail capability is included and is difficult to achieve with a custom-built solution.

All data is stored in an encrypted database with no direct access. Even administrators cannot change the audit log.

APPLICATIONS SUPPORTED

Selenium WebDriver LEAPWORK

SAP GUI SAP GUI is not supported. Selenium only supports web applications and it’s not possible to access elements in desktop applications outside the browser.

Works across all technologies. SAP GUI is natively supported.

Windows applications Windows applications outside browsers are not supported.

Works across all technologies. All Windows technologies such as WinForms and WPF are natively supported.

Guide to web automation

30

Citrix applications Citrix applications are not supported.

Works across all technologies. Citrix and other virtualization technologies are supported with advanced text and image recognition capabilities.

Mainframe

applications

Mainframe terminal applications are not supported.

Works across all technologies. Mainframe terminal applications are supported with advanced text and image recognition capabilities.

Java, IBM, and Oracle

applications

Java applications, including IBM and Oracle Forms are not supported.

Works across all technologies. Java, IBM, and Oracle Forms applications are natively supported, including the older Java 1.6 standard.

Selenium WebDriver LEAPWORK

Scheduling

No scheduler is included. Programmers can use a unit-test framework in combination with a custom-built scheduler or build pipeline.

Scheduling and ad-hoc running is included out of the box. Flows can also be triggered from a build pipeline or other third-party system.

Parallelization Can run in distributed, parallel environments, but requires programmers to build a custom automation framework (typically takes 6-9 months).

Can run in distributed, parallel environments out of the box, including on BrowserStack, Sauce Labs and Selenium Grid as well as on LEAPWORK agents, where web, desktop and virtual applications can be automated together.

TEST EXECUTION AND INTEGRATIONS

Guide to web automation

31

Selenium WebDriver LEAPWORK

Built-in REST API No REST API is included, but the WebDriver wire protocol is open source, and custom-built REST APIs can be made by programmers.

A full-fledged REST API is included out of the box, making it easy for DevOps to integrate with any third-party system.

Built-in CI/CD plugins Any CI/CD platformscan be used by custombuiltsolutions. Agood ecosystem andlots of code samplesexist on the internetfor professionalprogrammers to use.

All popular CI/CDplatforms can easily beintegrated by DevOpsusing plugins or theREST API.

Guide to web automation

32

a LEAPWORK whitepaper

Go Ahead, Automate Today

Try the LEAPWORK Automation Platform for yourself or book your product demonstration today.

BOOK DEMO START TRIAL