Question: How can I identify a DOM selector or XPath to use in a CloudWatch canary GUI Workflow Builder?

I'm trying to create a canary in Amazon CloudWatch using the GUI Workflow Builder. I'm receiving errors that indicate that I selected an incorrect DOM element, so I need to find a DOM selector or XPath.

Short descriptionIf you selected an incorrect DOM element when creating a canary with the GUI Workflow Builder, you might encounter the following errors:"Error: Node is either not visible or not an HTMLElement.""No test result returned. Error: Navigation failed because browser has disconnected!""TimeoutError: Waiting for selector""TimeoutError: Waiting for XPath"ResolutionDetermine the correct selector typeThe GUI Workflow Builder has five actions. The required selector type depends on the action and the runtime version that you use.Runtime versions use Node.js and Puppeteer, and the Verify text action uses the XPath selector. The following actions use the DOM selector:ClickVerify selectorInput textClick with navigationFor runtime versions that use Python and Selenium WebDriver, all actions use the XPath selector.Identify the correct selectorDOM selectorsTo find a unique attribute for your DOM:Open the context (right-click) menu for the element (such as a button, input field, div, span, or h1).Choose Inspect element (Mozilla Firefox) or Inspect (Google Chrome).Note the unique DOM attribute that you can use to identify your element (such as id, class, or name).If your DOM doesn't have a unique attribute, use one of the following methods to find the element:Use descendant selectors to match elements based on the given path or attribute. You must use the exact path. For example, to find <div class='new' id='newId'> <a href="/test1">test1</a> <a href="/test2">test2</a> <a href="/test3">test3</a> </div>, use div.new > a:first-child.Use attribute selectors to match elements based on the presence or value of a given attribute. For example, to find <div class="user-panel main" id="userId"> <input name="login"/> </div>, use div.user-panel.main input[name='login'].You can also get a unique DOM selector for your DOM element using your internet browser's Developer mode.Chrome:Open the context (right-click) menu for the element, and then choose Inspect.On the Elements tab, open the context (right-click) menu for the highlighted line.Choose Copy, and then choose Copy selector.Firefox:Open the context (right-click) menu for the element, and then choose Inspect Elements.On the Inspector tab, open the context (right-click) menu for the highlighted line.Choose Copy, and then choose CSS selector.Note: If there are multiple instances of the selector in the HTML document, then the canary selects the first element from the returned array. Avoid selecting elements that contain the display:none; CSS attribute. These elements are invisible and cause the selector to fail.XPath selectorsGet a unique XPath selector for your DOM element by using your internet browser's Developer mode.Chrome:Open the context (right-click) menu for the element, and then choose Inspect.On the Elements tab, open the context (right-click) menu for the highlighted line.Choose Copy, and then choose Copy XPath.Firefox:Open the context (right-click) menu for the element, and then choose Inspect Elements.On the Inspector tab, open the context (right-click) menu for the highlighted line.Choose Copy, and then choose XPath.Note: Before adding the XPath selector that you copied to the canary, remove the "//" prefix. The canary adds the "//" prefix to your code by default.Test the new selector and confirm that it's correctOpen Console mode in your internet browserChrome:At the top right of the browser, choose Customize.Expand the More tools option, and then choose Developer tools.With DevTools open in the browser, choose the Console panel.Firefox:At the top right of the browser, choose Open menu.Choose Web Developer, and then choose Web Console.Note: In some versions of Firefox, the Web Developer menu is located in the Tools menu.Test the DOM selectorThe syntax to test the DOM selector query in the browser console is: document.querySelectorAll("[AttributeName='AttributeValue']"). For example, if you have a div element with id='username', use the following pattern: document.querySelectorAll("[name='username']").Test the XPath selectorThe syntax to test the XPath query in the browser console is: $x("XPATH_QUERY"). For example, if you have a div element with id='welcome' that contains an h1 element, use the following pattern: $x("//div[@id='welcome']//h1). When you add this path to the canary, omit the "//" prefix.Add the new selector to the CloudWatch canaryOpen the CloudWatch console.For Synthetics, choose Canaries.Choose Create Canary.Choose Use a blueprint, and then choose GUI Workflow Builder.Refer to the example in GUI Workflow Builder to complete a blueprint that uses the newly created selector.