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.
Regexp in a _div( texte+number )
Hi all,
I made a search on all topics which talk about regexp but all my tries are on error
my case :
i've a _div composed by a text and a number between parenthesis like this
=> _div("Eric Besson (2)")
To test, i made : _highlight( _div("Eric Besson (2)") ); => it's ok
The number between parenthesis is never the same, so i try to put this number in a regexp [0-9]+
=> all my tries are on error
anybody could help me for this regexp syntaxe please ?
Thx
regards
Fabrice B
I made a search on all topics which talk about regexp but all my tries are on error
my case :
i've a _div composed by a text and a number between parenthesis like this
=> _div("Eric Besson (2)")
To test, i made : _highlight( _div("Eric Besson (2)") ); => it's ok
The number between parenthesis is never the same, so i try to put this number in a regexp [0-9]+
=> all my tries are on error
anybody could help me for this regexp syntaxe please ?
Thx
regards
Fabrice B
This discussion has been closed.
Comments
use _near ,_in,_under Api's
http://sahi.co.in/w/sahi-api-examples
Hi,
So sorry, but i dont see the link with regexp ?
Thank you
Regards
Fabrice B
its look like Indexing issue. regular expression not helpful for you in this scenario. please check in your page the same name is repeated somewhere that will be Eric Besson ,the second index is Eric Besson (1),third one is Eric Besson (2) .Sahi indexes the same text like this format. you have to use _near, under Api please check the same in the above url.
No i'm sorry i ve not be explicit enough
In fact i have a list of names followed by ("a number"), but i ve the name just one time, the number is only a count : i give you a part of innerHTML of my page
sahi recorder gives me : _div("Eric Besson (2)") : Great ! it's i prefer click on a explicit name instead of a gwtId,
So, i need to click on this _div, but the number between parenthesis is a count which change every time, every click change this count. So (again), i thought : if i use a regexp [0-9]+ i can click my _div without have to known the number...
Maybe it's not the right method ... What do you think of this?
Thank you for the time spent
Regards
Fabrice B
You can try using this:
_div("/^Eric Besson \(/");
Let me know if this solves your issue.
Regards
Sumitra
Sorry for the delay...
Sorry too for the solution, i obtained
_highlight( _div("/^Eric Besson \(([0-9]+)\)/") );
TypeError: el is undefined
and
_highlight( _div("/^Eric Besson \(/")) );
SyntaxError: missing ; before statement
Do you see another method than a regexp to do that ?
Regards
Fabrice B
Sumitra, You gave me idea... the parenthesis are the problem, but i dont need the parenthesis
_highlight( _div("/Eric Besson .*/") );
It's OK, Thank You
Thank you all for your searches
Fabrice B