Skip to content

User Guide

logigearcorp edited this page Jan 11, 2019 · 8 revisions

Welcome to the POMBuilder wiki!

This wiki contains documentation of POMBuilder. You can add this extension to Chrome here.

View, Copy and Paste Your Locator on the POM Builder Tab

  1. Right click on the element of interest
  2. Select Inspect
  3. Chrome DevTools opens up
  4. Under the Elements tab, select the POM Builder tab (usually the last tab)
  5. You can click directly on the DOM tree or use the Identify pointer of Chrome DevTools to select your desired element
  6. Smart Gen recommends the best locators for the selected element on the POM Builder tab
  7. Click the Copy button right after a locator to copy its value
  8. Click the Find button right after a locator to test it using Locator Test
  9. If you see that Locator Test returns 1/1 (the locator uniquely identifies the element), you're safe to use that locator. Copy it to the corresponding page object of your test project (Protractor, Selenium and TestArchitect).
  10. If Locator Test returns 0/0 or 1/X (the locator doesn't retrieve any element or the locator points to multiple elements), you must refine the locator until it returns 1/1

Quick Copy

  1. Right-click on the element of interest
  2. Select POM Builder – Quick Copy > ** There are 3 available selections: *** Suggested Locator: the most reliable locator that is recommended by POM Builder, you should use it for better performance and stability. It could be a single attribute, a CSS Selector or an XPath locator. *** CSS Selector: the CSS Selector that could uniquely identifies the selected element *** XPath: the XPath locator that could uniquely identifies the selected element
  3. After select your desired selector, the selected locator will be saved in the clipboard
  4. Feel free to paste it anywhere you want

Define New Output Templates

Currently, POM Builder supports 4 types of output:

  • Raw Value: the raw value of the element locator
  • Protractor: the locator template written in Typescript for Protractor projects
  • Selenium Java: the locator in the typical Java syntax used to locate elements in Selenium
  • TestArchitect: the interface elements used in TestArchitect

If you are using another test framework which has a different syntax, you could add a new output template, e.g. driver.findElement(webdriver.By.%type(%value)) in which %type and %value are the macros for the locator type ('Id') and its value ('someID') respectively. Remember to put them in your template for a valid locator output.

EXAMPLE Let's say you're using selenium-webdriver to write your Selenium tests in Javascript, and you have to define your element locators frequently as below:

To save time, you could take advantage of POM Builder Template Configuration feature to define your customized output template.

  1. Open POM Builder tab in Chrome DevTools

  2. Click the button

  3. In Template Configuration, click Add New

  4. Create a new output template named Selenium JS with the following information. Note that %type is the macro for the locator type and %value is the macro for the output value.

  1. Review the Example Result value to check whether your defined output is valid then click Apply to save the new template

  2. Selenium JS will appear in the Output dropdown list.

  1. Select it then copy a locator. The locator will be copied to clipboard in your pre-defined template.

  1. When you paste it to any editor, you'll see something like the below.

driver.findElement(webdriver.By.id(identifierId))

Clone this wiki locally
You can’t perform that action at this time.