How to select a generally named element by using HTML text?

Hi,

A page is coded in this manner of same “id” for its cell element in a list :slight_smile:

<span id="ui_button_label_">Do Payment</span>
<span id="ui_button_label_">Approve Payment</span>
<span id="ui_button_label_">Stop Payment</span>

(simplified coding to improve readability - took out other CSS stuff inside the “div” “tr” “td” stuff that package the above list element items)

Can advise if I can select a specific cell row?
Cuz if I use Kantu’s target = “id=ui_button_label” it will ALWAYS select the 1st element.
(SIDE: Seems to ignore the “value = Approve Payment” part totally etc)

Pardon me for this noob like question, still learning Kantu.

1 Like

Hello,

You can insert the index in xpath, use the syntax //span[@id=‘ui_button_label_’][2] where 2 means the 2nd row !

Julien

Hi Thank You, it worked! BUT… a strange issue…

After the prompt is closed upon a successful selection, the entire macro stopped with no Error Message or the countdown (to search for an element). It is as if it was disconnected but it is not. Traced back the logs and network - the connectivity and environment is good and healthy.

Is there a bug?

I have pasted the logs as below:

[info] Executing: | type | id=payment_interBankGiroVO_searchCode | RHBBSGSG |
[info] Executing: | click | id=ui_button_label_interbankSearchBtn | |
[info] Executing: | click | //*[@id=‘ui_button_label_pickListContent’][1] | |
[info] Executing: | selectFrame | relative=top | |
[info] Macro was stopped manually (Runtime 61.46s)

Hello

maybe you want a clickAndWait action in replacement of the click on “ui_button_label_pickListContent” ?
This would prevent the macro from going ahead before the page loads entirely.

Julien

Thanks for the “clickAndWait”,

Sorry but back to the XPath you shared with me, I wrote it for another test macro and it does not work. it only worked when //span[@id=‘ui_button_label_pickListContent’][1] but failed totally when //span[@id=‘ui_button_label_pickListContent’][2].

I had also tried other known syntax (on the single/double quote symbols) as screenshot below:

image

And the logs:
image

Please advise.

Is Kantu still being developed? I’m a new user and it seems like very, very few posts receive responses. You’d expect all of them to have responses in short order. This one is from 8/15/18!!!

Kantu is being developed and bigger updates are available soon for beta testers.

As for this forum post, this is a highly specific question and very difficult (if not impossible) to answer without access to the page. I guess that is why it has no new replies. Even we here at Kantu headquarters don’t know how to debug this without access to the website.

That said, Kantu will soon get computer vision features that will solve this kind of issues very elegantly :wink:

{
“Name”: “Test”,
“CreationDate”: “2019-8-1”,
“Commands”: [
{
“Command”: “storeText”,
“Target”: “xpath=(//*[@class=“w3-example”])[2]”,
“Value”: “varText”
},
{
“Command”: “echo”,
“Target”: “${varText}”,
“Value”: “”
}
]
}

Note: You need to add “xpath=” to the Target and (), otherwise it will fail