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.
How to get element by partial text?
I am using the function _containsText to help me identify labels that are not complete and I would like to know if it is possible to return the element ID of the offending label.
Example:
Label on screen says "file not found". I run my script and results tell me that "not found" is on the screen. I would like to return the whole label - "file not found".
Any ideas?
Example:
Label on screen says "file not found". I run my script and results tell me that "not found" is on the screen. I would like to return the whole label - "file not found".
Any ideas?
Answers
is that what u asked for?
you could use the _collect API to gather all elements and return the id
does that solve your problem?
Regards
Wormi
_collect('/./', '/not found/');
and please tell me if it worked
alternatively you could write a recursive funtion which crawles through your DOM tree
something like
I'm a bit stymied by the syntax of the _collect function
· · _collect(apiType, id, inEl)
... seems somewhat er uh succinct.
1. what do the "forward slashes" "/" indicate? (that regex syntax will work??)
2. what are [acceptable] "apiTypes"s - examples shows only "_link" which led me so far to successfully try similar HTML based items "_image" and "_div" and "_span".
3. If I buy the PRO version is the manual a bit more detailed?
^_^
(You can tell I'm enjoying this, close to success, because my questions are so picky *and* picayune!)
3. You can get the Pro Docs here, but it does not provide many more information on _collect http://sahi.co.in/w/file_download/5/SahiPro_V4_2_Documentation.pdf
2. The API types are everything Sahi recognizes like _link, _div, _span, _table, _cell ..... when you can access it with the Sahi Controller, you can collect it
1. The forward slashes are part of the regular expression, have a look here http://www.w3schools.com/jsref/jsref_obj_regexp.asp
Regards
Wormi