Skip to content

Commit

Permalink
Define generateLocator in ElementFactory (#91)
Browse files Browse the repository at this point in the history
- to be used for non-xpath generation in aquality.selenium
  • Loading branch information
mialeska authored Jan 25, 2024
1 parent e8c7196 commit 0caad73
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public <T extends IElement> List<T> findElements(By locator, String name, IEleme
for (int index = 1; index <= webElements.size(); index++) {
WebElement webElement = webElements.get(index - 1);
String currentName = String.format("%1$s %2$s", namePrefix, index);
T element = supplier.get(generateXpathLocator(locator, webElement, index), currentName, state);
T element = supplier.get(generateLocator(locator, webElement, index), currentName, state);
list.add(element);
}
return list;
Expand Down Expand Up @@ -126,6 +126,18 @@ public <T extends IElement> List<T> findElements(By locator, String name, Class<
return findElements(locator, name, elementSupplier, count, state);
}

/**
* Generates locator for target element.
*
* @param multipleElementsLocator locator used to find elements.
* @param webElement target element.
* @param elementIndex index of target element.
* @return target element's locator
*/
protected By generateLocator(By multipleElementsLocator, WebElement webElement, int elementIndex) {
return generateXpathLocator(multipleElementsLocator, webElement, elementIndex);
}

/**
* Generates xpath locator for target element.
*
Expand Down

0 comments on commit 0caad73

Please sign in to comment.