27
Object Spy, Visual Analysis and XML/Xpath Intro and Demo for Partners David Broerman Partner Enablement Manager Email: [email protected]

TechTalk: Advanced Practices for Visual Test Automation

Embed Size (px)

Citation preview

Page 1: TechTalk: Advanced Practices for Visual Test Automation

Object Spy, Visual Analysis and XML/XpathIntro and Demo for Partners

David BroermanPartner Enablement ManagerEmail: [email protected]

Page 2: TechTalk: Advanced Practices for Visual Test Automation

Agenda

• Intro to Perfecto• XML and Xpath and Objects

• What are XML and Xpath?• Working with XML and Xpath• Object Analysis and the Perfecto Object Spy

• What is Visual Analysis• Best Practices with Perfecto

• DemoPerfecto Automation

• Discuss Object Spy , Visual and XpathReview a Perfecto Lab Selenium/Appium Project in Eclipse

• Discuss Object Spy , Visual and Xpath• Q&A

Page 3: TechTalk: Advanced Practices for Visual Test Automation

Intro to Perfecto

Perfecto Offers:

A Cloud Based Continuous Quality Lab

enabling testing and monitoring of all digital platforms

on real devices and real end user conditions,

for enterprises adopting agile delivery processes.

05/03/2023 3

Page 4: TechTalk: Advanced Practices for Visual Test Automation

Intro to Perfecto

Dominant leader & visionary

Strong Ecosystem

Perfecto @ a glance

Working with Enterprises and Partners to deliver exceptional digital experiences.

4

Setting the bar for market success

• Founded in late 2006, Business HQ in Boston • Over 300 employees globally• Fortune 500 customer base

05/03/2023

“Perfecto Mobile marks shift in mobile apps quality with Continuous Quality Lab”

Page 5: TechTalk: Advanced Practices for Visual Test Automation

Cloud Based Quality Platform For The Digital Era

05/03/2023 5© 2017, Perfecto Mobile Ltd. All Rights Reserved.

Open & Integrated into Dev/Test/Ops

Any test tool

Any CI server

Any test framework

Any IDE

Any Location

Code/Debug Functional Test Performance Test

Production Insight

One Lab for all Digital Platforms

Reporting & Analytics

Wind Tunnel Layer

Customer Support

Browsers Desktops Mobile Devices IoT

Page 6: TechTalk: Advanced Practices for Visual Test Automation

Open and Integrated

6

Open & Integrated

Xcode

Selenium

05/03/2023

Page 7: TechTalk: Advanced Practices for Visual Test Automation

What are XML and Xpath?

• XML • EXtensible Markup Language• XML enables you to create data that can read by any application on any

platform• Native Object analysis relies on XML• The Object Tree is an XML document

• Xpath (XML Path Language)• XPath is the query language for XML documents

• Describes a way to locate and process items in XML documents• In automation, Xpath allows us to identify the object/objects

Page 8: TechTalk: Advanced Practices for Visual Test Automation

Importance of Understanding XML and XPath

8

• Native Object analysis relies on XML • Retrieves the XML document and analyzes it • However, it this is not enough to identify the object using its location in the

object tree. This approach is fragile.• It is necessary to use specific XPath expressions to uniquely identify the object. • This will enable your object to be found across multiple platforms and

devices.

Page 9: TechTalk: Advanced Practices for Visual Test Automation

9

Native Objects Analysis

• The Object Tree is an XML document

• The way to find elements inside XML is through XPath

• To properly work with Objects, a good grasp of XML/XPath is needed.

Page 10: TechTalk: Advanced Practices for Visual Test Automation

The Perfecto Approach for Mobile Objects

Native Object Analysis

and

Visual Object Analysis = HYBRID APPROACH!

Best Practice: Use Native Object Analysis for Navigating and Visual/OCR for Validation.

ProsCons

Page 11: TechTalk: Advanced Practices for Visual Test Automation

The Object Spy enables working with objects

• The Object Spy accesses the XML of the application

• Identifies the element and writes an XPath Expression.• May need to export the XML into Firebug/FirePath.• Inserts the expression back into the Object Spy.• Applies the required action:

• Click – click on the element• Set – an edit field with a value• Info – to retrieve an element to receive its properties• Find – find an element

Page 12: TechTalk: Advanced Practices for Visual Test Automation

Website & Apps – Object Trees/Identifying Objects• Web Objects

• DOM• Same Tree (PM or Appium

Framework)

• Native App Objects• PM or Appium framework• Appium -Separate naming for

Android and iOS• Perfecto – Script Once

• Hybrid Application• PM automation framework• Mix of Native and DOM objects

DOM Perfecto Mobile

Appium

Page 13: TechTalk: Advanced Practices for Visual Test Automation

Working with the Object Spy

Selected Automation Function and Parameter fields

Object XPath

Object TreePreview Panel

Search and

Export

Filter displayed Objects

Object Properties

Automation functions

associated with the selected object type

Page 14: TechTalk: Advanced Practices for Visual Test Automation

Adding Commands from the Object Spy

Page 15: TechTalk: Advanced Practices for Visual Test Automation

15

Working with Firebug and FirePath

Page 16: TechTalk: Advanced Practices for Visual Test Automation

Object Spy: Object Locator Available –

• Object Locator is available for Native, Web and Hybrid apps.• Easily generate

accurate XPath identifiers from within the Perfecto Object Spy • Don’t have to

export to XML and use tools such as FireBug and FirePath.

Page 17: TechTalk: Advanced Practices for Visual Test Automation

Visual Analysis

• Visual analysis is an alternative way of interacting with a device. • Its’ source is the screenshot taken from the device (what the user sees).

• Perfecto can analyze the screenshot looking for either text or images, with text being the recommended option.

Best Practice: Use Native Object Analysis for Navigating and Visual for Validation.

Page 18: TechTalk: Advanced Practices for Visual Test Automation

Visual - Available Commands• Select - Clicks on the image/text

• Find – Finds an image/text for visual relationship

• Check – A Checkpoint that validates the text/image appears on the screen• (Sync is same command , Sync has a default timeout of 60 seconds and check does not)

• Button – Clicks a Button

• Edit - Sets a value inside an input field

05/03/2023 18© 2015, Perfecto Mobile Ltd. All Rights Reserved.

Page 19: TechTalk: Advanced Practices for Visual Test Automation

Example - Coding Visual Analysis – Java

• Visual Analysis – Perfecto Proprietary command executed using RemoteWebDriver• Use the

executeScript method• The script

parameter contains the command name, in the following format: mobile:command:subcommand.

05/03/2023 19© 2015, Perfecto Mobile Ltd. All Rights Reserved.

Map<String, Object> params3 = new HashMap<>();// Check for the text that indicates that the sign in was successfulparams3.put("content", "Welcome back John");// allow up-to 30 seconds for the page to displayparams3.put("timeout", "30");resultString = (String) driver.executeScript("mobile:checkpoint:text", params3);if (!resultString.equalsIgnoreCase("true")) {System.out.println("'Welcome back John' text not found");}

Page 20: TechTalk: Advanced Practices for Visual Test Automation

Did You Know?

•When talking with users of the Perfecto Solution• Approximately 90% of testing defects are found using Visual

Validation!• Mobile is different as we want to understand the UX• Need to see what the user sees• An object on the screen may be found, but it may be hidden behind

something else (need visual validation).

Page 21: TechTalk: Advanced Practices for Visual Test Automation

XPath Examples

Page 22: TechTalk: Advanced Practices for Visual Test Automation

Example of Power of Xpath with Objects

22

Let's say that we want to work on a username field.

Remember:· The default path generated by the Object Spy refers to its location; its placement on the page.· The placement of that object can change, or be slightly different in another platform

(i.e. tablet vs. smartphone).· So, it's important to refer to it by its logical function instead of an arbitrary placement on the

page.

XPath will allow this to be specified: //[@username]· This expression explicitly refers to the input field called 'username'.

Advantages: It is easy to read. It is likely to work well with minimal maintenance. It is likely to be identical across devices and platforms.

Page 23: TechTalk: Advanced Practices for Visual Test Automation

23

XPath Expression Syntax

Expression Description

nodename Selects all nodes with the name "nodename"

// Selects nodes in the document from the current node that match the selection no matter where they are

//vehicle Selects all vehicle elements no matter where they are in the document

//@make Selects all attributes named make

//*[@make="Toyota"] Select all attributes named make with value of Toyota

//vehicle[@*] Selects all vehicle elements which have any attribute

//*[text()=’Corolla’] Select all objects with the text Corolla

//vehicle[2] Select the second vehicle element

Page 24: TechTalk: Advanced Practices for Visual Test Automation

Demo• Open Perfecto Automation and also Open existing Perfecto Lab

Selenium/Appium Project in Eclipse• Discuss Object Spy , Visual Analysis and Xpath

Page 25: TechTalk: Advanced Practices for Visual Test Automation

Resources• Sample script and Demo Apps• https://community.perfectomobile.com/series/25427/posts/1064930

• Working with Object Spy and XPath• https://community.perfectomobile.com/posts/914140-web-objects

• XPath Tutorial• http://www.w3schools.com/XPath/

• XML Tutorial• http://www.w3schools.com/xml/

Page 26: TechTalk: Advanced Practices for Visual Test Automation

Q&A

Page 27: TechTalk: Advanced Practices for Visual Test Automation

Thank You

David BroermanPartner Enablement ManagerEmail: [email protected]