Presentation is loading. Please wait.

Presentation is loading. Please wait.

Leveraging Objects with XPath

Similar presentations


Presentation on theme: "Leveraging Objects with XPath"— Presentation transcript:

1 Leveraging Objects with XPath

2 The Perfecto Object Spy Working with XPath
Agenda The Perfecto Object Spy Working with XPath Correctly identifying objects In the previous module we got introduced to object analysis and learned why identification of XML elements via XPath is the key to working with objects. If you skipped the last module and are unfamiliar with either XML or XPath, please go back to it before starting this module. This module starts where the previous one ended, and focuses on working with objects on mobile applications and websites using Perfecto Mobile

3 The Object Spy

4 The Object Spy The Object Spy is the tool that enables working with object We will use the Object Spy to access the XML of the application Export the XML into firebug Identify the element and write XPath Expression Insert the expression back in the Object Spy Apply 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 These are the steps to work with objects, we will now drill down and show you step-by-step

5 Here is the login screen of the Perfecto Mobile demo application
Taking a closer look Here is the login screen of the Perfecto Mobile demo application The Password edit field and the automatic XPath generated by the Object Spy [Trainer] Before starting you should have an Android and iOS device with the PM demo application already installed on them. Open the iOS device start the PM demo application open the Object Spy once the Object Spy completes loading, filter out everything except for “Edit fields” using the Filter click on the “Password” edit field. select the “Application.element.set” command (from the automation functions window) Important Note: you need to use the filter because the edit field object can be hidden behind other objects.]

6 Working with the Object Spy
The following slides will describe how to use the Object Spy. Step 1: Exporting the page Open the MobileCloud in the Firefox browser Navigate to the desired device screen Wait for the page completely load Open the Object Spy (click on the open button located in the Common Functions sidebar menu in the Automation tab) Export the page using the Export Tool (this will open a separate tab in the browser) Continued on next slide…

7 Working with Firebug and FirePath
Step 2: Reading the XML document Open Firebug (top right of the Firefox browser menu bar) Inspect the element you want to work with by clicking on the Firebug inspector and then on the object in the page The object in the page and the location of it in the tree will be highlighted. Also, a default XPath will be automatically provided. Read the XML, understand what makes the element unique and write an XPath that will be able to find it (more on writing XPath expressions later on) Continued on next slide… Note: More on how to write XPath expressions will be covered later.

8 Adding Commands from the Object Spy
Step 3: Testing the XPath expression Go back to the Object Spy and use the Search Tool (you can also test your XPath in FirePath) Input the XPath and click on the search icon to check that the object is found Step 4: Adding commands to the Automation script Click on the object in the preview panel Replace the default XPath with the one you have created Edit any necessary parameter field values Click Add to add the function to your script Optional: enable Execute on Add in the Object Spy to keep the Object Spy window open for additional functions (refresh the Object Spy preview panel to see the updated device screen) Recap We saw the object spy and did the full loop, starting in the mobile application, using the object spy to export the XML, writing the Xpath expression and then copying it back to the object spy. Once the correct expression was in the Spy, we selected the appropriate command, and with “execute on add” we are ready for the next step in the script. This flow is identical for mobile applications and websites and repeats whenever we want to work with objects. We are now finished with learning the object spy. We had a lot of theory, the next part of the module will focus on the demo applications, highlighting different xpath expressions and seeing it work in the real world.

9 XPath Examples The following slides contain expressions written for various objects in the PM demo applications. Go through the expressions, emphasizing WHAT the expression is saying in plain English, and WHY it is saying it. The sample script Working with Objects runs on the same demo applications, you can run it and show the expressions live with the class.

10 Identifying the Password text field
All Elements attribute named resourceid with value of com.example.testapp:id/etPass In this case, the element can be identified by its attribute: resourceid However, the attribute is not unique. So, we add the attribute value to the XPath expression Use the Application.Element.Set command to set the password text field to “Perfecto1”. The specific <secure> node is selected using the resourceid attribute. This path expression, with a predicate, selects all elements that have an attribute named resourceid with a value of “com.example.testapp:id/etPass”.

11 Identifying the Login button
//*[text()=“Login”] All Elements node test text() with value of Login The unique property of the login button it is the only element that has the value of “Login”. That is why, we can ignore in the expression the element name and its attributes Use the Application.Element.Click command to click on the “Login” button. The specific <button> node is selected using the resourceid attribute. By Text is translated into a node test that searches all elements with the value Login. Note: What is a node test?

12 Identifying the Continue button
//button[text()=“Continue”] All Elements node test text() with value of Continue of button element In this example, we will be more specific and require both the element name and its value. Note the // at the beginning of the expression, it denotes that the element can appear anywhere within the tree Using text() on its own is still not powerful enough… pairing button and text() in your query specifies exactly the object you are looking for. Use the Application.Element.Info command to retrieve the “Continue” button info, specifically the package property value. The specific <button> node with the value Continue is queried.

13 Identifying the First Screen button
//button[starts-with(text(),“First”] All Elements node test text() with value of First with button element name Element named button Whose value begins with the word “First” that start with Use the Application.Element.Click command to click on the “First Screen” button. The button is identified using the starts-with function.

14 Identifying the Radio buttons
All Elements with value of true attribute named checkable In this case we identify several elements by attribute name and value We can use the Find command to then analyze the results Use the Application.Element.Find command to find the elements in the application that have an attribute named checkable with a value of “true”.

15 Thank You


Download ppt "Leveraging Objects with XPath"

Similar presentations


Ads by Google