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.
regualr expression for extracting all elements
My html page contains following elements, And there are 40 such elements in the page
<input class="txtTblReslt size33" type="text" maxlength="50" value="P" name="UserDefinedLabelsList.P"/>
<input class="txtTblReslt size33" type="text" maxlength="50" value="C Num" name="UserDefinedLabelsList.C Num"/>
Its actually a text box with pre-defined data in it.
When i want to extract all of those i use regular extraction,
_debug(_textbox(new RegExp(/UserDefinedLabelsList\..*/g)).value);
I was assuming 'g' is for global.
I failed to extract all the label/text and it return me only the first value i.e 'P'
Can someone suggest a solution for this?
Thanks.
<input class="txtTblReslt size33" type="text" maxlength="50" value="P" name="UserDefinedLabelsList.P"/>
<input class="txtTblReslt size33" type="text" maxlength="50" value="C Num" name="UserDefinedLabelsList.C Num"/>
Its actually a text box with pre-defined data in it.
When i want to extract all of those i use regular extraction,
_debug(_textbox(new RegExp(/UserDefinedLabelsList\..*/g)).value);
I was assuming 'g' is for global.
I failed to extract all the label/text and it return me only the first value i.e 'P'
Can someone suggest a solution for this?
Thanks.
Comments
Can you please let me know a solution for this?
Thanks,
Kirthi
APIs in Sahi return you a single element. They do not return a collection. The regular expression based match will also return the first matched element.
Looking at your snippet, it looks like all these have the same class. You could use
_textbox("txtTblReslt size33[0]") to _textbox("txtTblReslt size33[39]") to access each of these elements.
Eg.
You can also use a browser function to collect all necessary values and then use it.
The second method is faster than the first.
Hope that helps.
-Narayan