Using Index Variable in Locator to Find A Series Elements

1. Introduction #

Clicknium’s Locator supports a parametric locator, which can be utilized by users in their automation projects to replace variables or data. By doing so, the locator can match a series of elements rather than just a single one.

To illustrate how to use an index variable in the locator to identify a series of elements, there are two automation cases available.

Note: For more about the installation and the tutorial of Clicknium Automation, please refer to here.

2. Automation Case-1 #

Case Description : Scraping contact list on the slack client,Scraping contact list on the Slack client to obtain user information.

Slack channel – Contact list

After recording one contact item’s locator, the user modifies the locator with an index variable.

Then use loop traversal to locate each contact element and get information.

for i in range(1,13):
    dict = {"index":i}
    if not cc.is_existing(locator.slack.listitem_member, dict):
    elem_member = ui(locator.slack.listitem_member, dict)
    name = elem_member.get_text()

3. Automation Case-2 #

Case description:Scraping playlist from Spotify. It is an actual user scenario, which needs to get the playlist information from spotify.

First, locate “author” and “title” from one item in the playlist.

As the Spotify page is complicated and dynamic, users use “XPath” in the locator.
Modify the locator with the index variable.

Then use loop traversal to locate each item in the playlist and get information.

tab ="")
index = 2

titles = []
artists = []
links = []
while True:
    if not tab.is_existing(, {'index':index}):
    title = tab.find_element(, {'index':index}).get_text()
    artist = []
    link = []
    element = tab.find_element(, {'index':index})
    authers = element.children
    for item in element.children:

    index += 1
What are your feelings
Updated on 4 December 2023