Regular expression in Value


#1

Hello

I would like to use a regular expression in the value of AssertText because I need to identify two numbers followed by a percent (so I can’t use the wildcard *), but this does not seems to work in Kantu. I didn’t find any clue in the documentation.

Here are the tests I made with no luck :
assertText | //span[@id=“txrecouvrement”] | [0-9][0-9]% |
assertText | //span[@id=“txrecouvrement”] | regexp:[0-9][0-9]% |
assertText | //span[@id=“txrecouvrement”] | regex:[0-9][0-9]% |
assertText | //span[@id=“txrecouvrement”] | regex=[0-9][0-9]% |

I’ve also tried to use assertElementPresent with regular expression in xpath but I always get a “DOM not found” error (although it’s working fine with the contains() function )

assertElementPresent | //span[@id=“txrecouvrement”][matches(.,’[0-9][0-9]%’,‘i’)] |
assertElementPresent | //span/text()[matches(., ‘[0-9]+’)] |

Can you help me ?
Thank you


#2

Regular expression are not yet supported with the assert… commands like assertText or assertElementPresent.

Suggested workaround: Use sourceSearch, it fully supports regex.

The sourceSearch and sourceExtract commands work with the page source, instead of looking at the web page object model (DOM) that all other “classic” Selenium IDE command use. Thus sourceSearch/Extract also “sees” e. g. comments in the page source code and can check/extract Javascript code parts (like the Google Analytics ID) that are invisible to a command like storeText.


#3

Thank you for your answer, I finally found a “twisted” way do that with storeText+storeEval.
I hope that regular expression support with assert* will be planed in a future release !


#4

It seems you can now use wildcards for the text you are searching for.

| * text * will find sometext
| text wil not match sometext