Dawn Christine Simmons
Dawn Christine Simmons
  • Home
  • Services
  • Portfolio
  • About
  • Blog
  • Knowledge Base
  • Resume
  • Contact
  • Get Started

AutomatePro AutoTest Custom-Testing

  • Home
  • AutomatePro
  • AutomatePro AutoTest Custom-Testing
AutomatePro AutoTest Custom-Testing
  • June 27, 2024

AutomatePro AutoTest Custom-Testing Introduction: insight into the capability to more advancedd techniques to extend and customize the testing process within ServiceNow. Learn how to use the output of ServiceNow Lookup Records to determine action inside a custom action. This guide will introduce you to the concept of custom checks and actions, providing simple definitions and a comprehensive overview of creating and configuring these customizations. You will also learn how to use:

  • XPath
  • CSS selectors
  • Work with frames
  • Handle shadow roots.

AutomatePro AutoTest Custom-Testing Definitions:

Custom Actions:

These are specific interactions with elements on a web page that you define to automate testing processes. Here is a practical example:

Imagine we want to click a button with a specific id attribute on a webpage.

  1. Define the Custom Action:Python@action( methods=["POST"], detail=True, url_name="submit", url_path="submit", lookup_field="id" # Use the 'id' attribute for lookup ) def submit_form(self, request, pk=None): # Your custom logic here pass
  2. Explanation:
    • We’ve defined a Custom Action called submit_form.
    • The lookup_field parameter specifies that we’ll use the id attribute for locating the button during runtime.
  3. During Execution:
    • When the Custom Action runs, it will search for an element with the specified id.
    • If the button’s id matches the lookup value (e.g., submit-button), the action will click it.

Remember, lookups make your Custom Actions more robust and adaptable. You can easily adjust to changes in the page structure without rewriting your code.

XPath Selectors:

A language used for locating elements on a web page based on their hierarchy and attributes. XPath selectors are powerful tools for navigating and selecting elements within an XML document or an HTML page. Let’s look at a simple example using the following HTML snippet:

HTML

<div id="container">
    <h1>Welcome to My Website</h1>
    <p>Explore our content!</p>
    <button id="submit-button">Click Me</button>
</div>
  1. XPath Path Notation:
    • XPath uses path notation to traverse down into an XML document or an HTML page.
    • For example, the expression /div/h1 would select the <h1> element inside the <div> with the id="container".
  2. Selecting the Button Element:
    • To select the button with the id="submit-button", we can use the XPath expression://button[@id="submit-button"]
    • Breakdown:
      • //button: Selects any <button> element.
      • [@id="submit-button"]: Filters by the id attribute equal to "submit-button".
  3. Using the Expression:
    • In Python (using libraries like lxml or xml.etree.ElementTree), you can evaluate this XPath expression against your HTML content to find the button element.

XPath expressions can be more complex, allowing you to navigate through various levels of the document and filter elements based on attributes, and text content. For more detailed reference, check out the W3Schools XPath tutorial or the XPath vs CSS Selectors guide.

CSS Selectors:

A pattern used to select and style elements on a web page based on their attributes and styles.

CSS selectors allow you to target specific HTML elements for styling. Here are some common examples:

  1. Element Selector (element):
    • Selects all instances of a specific HTML element.
    • Example:CSSp { text-align: center; color: red; } AI-generated code. Review and use carefully. More info on FAQ.
    • In this case, all <p> elements will be center-aligned and have red text1.
  2. ID Selector (#id):
    • Selects an element with a unique ID attribute.
    • Example:CSS#para1 { text-align: center; color: red; } AI-generated code. Review and use carefully. More info on FAQ.
    • The rule above applies to the element with id="para1"1.
  3. Class Selector (.class):
    • Selects elements with a specific class attribute.
    • Example:CSS.center { text-align: center; color: red; } AI-generated code. Review and use carefully. More info on FAQ.
    • All elements with class="center" will be red and center-aligned1.
  4. Combining Class and Element (element.class):
    • Selects specific elements with a particular class.
    • Example:CSSp.center { text-align: center; color: red; } AI-generated code. Review and use carefully. More info on FAQ.
    • Only <p> elements with class="center" will be affected1.
  5. Universal Selector (*):
    • Selects all HTML elements on the page.
    • Example:CSS* { text-align: center; color: blue; } AI-generated code. Review and use carefully. More info on FAQ.
    • Every element will have centered text and blue color1.
  6. Grouping Selector:
    • Combines multiple selectors with the same style definitions.
    • Example:CSSh1, h2, p { text-align: center; color: red; } AI-generated code. Review and use carefully. More info on FAQ.
    • All <h1>, <h2>, and <p> elements will share the same styles1.

Frames (iframes):

HTML elements used to embed content from other sources, requiring context switching to interact with their content.

Let’s explore how to use iframes (inline frames) in HTML. An iframe allows you to embed another web page within your current page. Here are some examples:

  1. Basic Iframe:
    • To embed a webpage, use the <iframe> tag with the src attribute pointing to the desired URL:HTML<iframe src="https://www.example.com" width="600" height="400" frameborder="0"></iframe> AI-generated code. Review and use carefully. More info on FAQ.
    • This displays the content of https://www.example.com within the iframe.
  2. Customizing Iframe Size:
    • You can set the height and width using attributes or inline styles:HTML<!-- Using attributes --> <iframe src="demo_iframe.htm" height="200" width="300" title="Iframe Example"></iframe> <!-- Using inline styles --> <iframe src="demo_iframe.htm" style="height:200px;width:300px;" title="Iframe Example"></iframe> AI-generated code. Review and use carefully. More info on FAQ.
  3. Removing the Border:
    • By default, iframes have a border. To remove it, add the style attribute:HTML<iframe src="demo_iframe.htm" style="border:none;" title="Iframe Example"></iframe> AI-generated code. Review and use carefully. More info on FAQ.

Shadow Roots:

Encapsulated parts of the DOM used by web components, which require special handling to access nested elements.

Creating and Configuring AutomatePro AutoTest Custom-Testing:

Creating Custom Actions

Firstly, custom actions in AutomatePro AutoTest allow you to define specific interactions with web page elements. To get started, follow these steps:

  1. Navigate to the Custom Actions module in AutomatePro.
  2. Click on “Create New Action” and provide a descriptive name.
  3. Define the action type, such as click or input text, and set the required parameters.

Configuring Custom Actions

Next, configure the custom action to integrate it into your test scripts. Here’s how:

  1. Action Type: Select the appropriate action type from the options available.
  2. Target Selector: Use XPath or CSS selectors to accurately identify the target element.
  3. Parameters: Set additional parameters required for the action, such as input values or expected results.

Using XPath and CSS Selectors

XPath Selectors

Firstly, XPath (XML Path Language) is a powerful tool for locating elements based on their hierarchy and attributes.

  • Basic Syntax:xpathCopy code//tagname[@attribute='value'] For example:xpathCopy code//input[@id='username']
  • Advanced Usage:
    • Contains: //tagname[contains(@attribute, 'value')]
    • Text: //tagname[text()='value']

CSS Selectors

Additionally, CSS selectors are straightforward and fast for selecting elements based on their styles and attributes.

  • Basic Syntax:cssCopy codetagname#id .classname For example:cssCopy codeinput#username .login-button
  • Advanced Usage:
    • Attribute Contains: [attribute*='value']
    • Child: parent > child

Understanding the Use of Frames

Working with Frames

Moreover, web pages often use frames (iframes) to embed content from other sources. Therefore, when dealing with frames, ensure your custom actions and checks can access the elements within these frames.

  • Identify Frame: Use developer tools to inspect the iframe and get its attributes.
  • Switch Context: Configure your custom action to switch to the frame context before interacting with elements.javascriptCopy codedriver.switchTo().frame("frameNameOrId");
  • Nested Frames: Handle nested frames by sequentially switching to each frame in the hierarchy.

Exploring Shadow Roots

Understanding Shadow DOM

Furthermore, Shadow DOM is used for encapsulating the internal structure of web components. Elements within shadow roots are not accessible via standard selectors unless the shadow root is expanded.

  • Accessing Shadow DOM:
    • Basic Approach:javascriptCopy codeconst shadowRoot = element.shadowRoot; const shadowElement = shadowRoot.querySelector('selector');
  • Expand Shadow Roots: Ensure your custom actions can expand shadow roots to access nested elements.javascriptCopy codeconst shadowHost = document.querySelector('shadow-host-selector'); const shadowRoot = shadowHost.shadowRoot; const targetElement = shadowRoot.querySelector('target-selector');

Other Resources AutomatePro AutoTest Custom-Testing:

  • AutomatePro AutoTest Reference
  • AutomatePro AutoTest: Getting Started
  • MDN Web APIs documentation on shadow DOM
  • W3Schools XPath tutorial 
  • XPath vs CSS Selectors guide

Share:

Previus Post
ServiceNow CMDB
Next Post
Digital Excellence

Comments are closed

Archives

  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • September 2022
  • March 2022
  • February 2022
  • January 2022
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • March 2021
  • January 2021
  • December 2020

Categories

  • Agile
  • Agile DevOps CI/CD
  • AI: Generative Artificial Intelligence
  • Apple
  • Arts and Entertainment
  • Athletics and Sports
  • AutomatePro
  • Blog
  • Branding
  • Business Communications
  • Chicago
  • client
  • Clients
  • Cyber Security
  • Design
  • Digital Business Process
  • Foodies Corner
  • Generative AI
  • Global News & Views
  • Governance – GRC
  • Healthcare
  • Jobs n Career
  • Portfolio
  • ServiceNow
  • Success & Motivation
  • Success and Miotivation
  • Team
  • Watchlist

Categories

  • Agile (5)
  • Agile DevOps CI/CD (6)
  • AI: Generative Artificial Intelligence (28)
  • Apple (1)
  • Arts and Entertainment (26)
  • Athletics and Sports (7)
  • AutomatePro (141)
  • Blog (43)
  • Branding (1)
  • Business Communications (22)
  • Chicago (17)
  • client (2)
  • Clients (24)
  • Cyber Security (7)
  • Design (2)
  • Digital Business Process (16)
  • Foodies Corner (10)
  • Generative AI (7)
  • Global News & Views (35)
  • Governance – GRC (6)
  • Healthcare (49)
  • Jobs n Career (26)
  • Portfolio (1)
  • ServiceNow (26)
  • Success & Motivation (53)
  • Success and Miotivation (2)
  • Team (5)
  • Watchlist (27)

Tags

automatepro bangladesh best practices careers Chicago dawncsimmons Dawn Khan Dawn Mular Dawn Simmons denver metro HDI employment Executive Womens Network hdi healthcare heart attack Help Desk hiring ITIL IT Service Management itsm itsmf jahir rayhan jobs jobsncareers laid off layoff leadership Long-Covid long COVID Long COVID symptoms process improvement recruiters remote work servicedesk service management servicenow ServiceNow best practices silicon valley Sun Microsystems talent telecommute telework thirdera WOMEN IN TECH work from home

Recent Posts

  • AutomatePro’s Fastest Release Yet
  • AI Gender-Gap Bias Impact
  • Resolving AI Gender Bias
  • IWD: AI Service Management
  • IWD: Dr. Fariah Mahzabeen

Recent Comments

  1. Career Width on IT Technical Project Manager Career Outlook and Project Integration Story: SCCM to ServiceNow CMDB
  2. backlinks generator for youtube on ServiceNow World Forum Chicago
  3. Dawn Christine Simmons on Response: Lipton Unsweetened Return
  4. Dawn Christine Simmons on Dexcom G7 Failure Fix
  5. Dawn Christine Simmons on Dexcom G7 Failure Fix

Copyright © 2025 All Rights Reserved by Dawn C Simmons

  • Home
  • Blog
  • Knowledge Base
↑