18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
click link matching regex for outerHTML
I have a page which lists some items with the same link name, however the outerHTML is includes a unique value. So I need a regex match and click on the relevant link
here is the html i have -
<td>
<a id="recurring_postings:view_scheduled_postings_table:1:recurTransferPostingIdLink" href="#" onmousedown="showPleaseWaitMousedown();" onmouseup="showPleaseWaitMouseup(event);" onclick="document.forms.value='recurring_postings:view_scheduled_postings_table:1:recurTransferPostingIdLink';document.forms.value='ACH_COLLECTION-990000033-110815:19:07:01:136';document.forms.value='batch_payment'; document.forms.submit(); return false;">Batch</a>
</td>
So here link text is "Batch" and it has value as 'ACH_COLLECTION-990000033-110815:19:07:01:136' which can be used to match the pattern
I have tried something like
_click(_link(/Batch/).outerHTML.match(/ACH_COLLECTION-990000033-110810:15:22:03:897/));
and I get ---- [Exception] Error: The parameter passed to _click was not found on the browser
Can somebody help me resolve this?
here is the html i have -
<td>
<a id="recurring_postings:view_scheduled_postings_table:1:recurTransferPostingIdLink" href="#" onmousedown="showPleaseWaitMousedown();" onmouseup="showPleaseWaitMouseup(event);" onclick="document.forms.value='recurring_postings:view_scheduled_postings_table:1:recurTransferPostingIdLink';document.forms.value='ACH_COLLECTION-990000033-110815:19:07:01:136';document.forms.value='batch_payment'; document.forms.submit(); return false;">Batch</a>
</td>
So here link text is "Batch" and it has value as 'ACH_COLLECTION-990000033-110815:19:07:01:136' which can be used to match the pattern
I have tried something like
_click(_link(/Batch/).outerHTML.match(/ACH_COLLECTION-990000033-110810:15:22:03:897/));
and I get ---- [Exception] Error: The parameter passed to _click was not found on the browser
Can somebody help me resolve this?
Comments
We can give you a solution for this, but it looks incorrect to be matching by some value in the onmouseover property. Is it not possible to use _near to find the link near to some other element which is more meaningful?
Regards,
Narayan
I sent you an email with a screenshot, I did tried using near as below, but again it clicked on the first link on the page.
_click(_link(/Batch/), _near(_link(/Batch/).outerHTML.match($sBatch))); //$sBatch is variable which hold the match pattern
I can write a function to use the for loop, match the text with outerHTML and get the id of the link. But I am trying to avoid that route and keep it simple in one liner. So if you have some solution it will be very helpful.
thanks,
Sumeet