I've looked at dozens of answers to this question, and tried all of them, but can't get any of them to work. I'm sure it's something very simple, but here's what I'm trying to do;
I need to extract a numeric value from a string, then compare it to see if it is greater than or equal to a number. I am using Selenium IDE.
The string is simple XXX Total matches
where XXX
is the number. I've stored this string using storeText
, storing it in a variable named appropriately enough, String.
I then run an echo
command to display "String" to make sure I've got that part correct, and it displays the "XXX Total matches" string as expected.
I have tried several methods mentioned on extracting the number part of the string, including regexp, javascript, etc.
The one that "seems" to work is storeeval | String=String.slice(0, 2); | Number
, but when I try to echo Number, it shows nothing.
I've tried
javascript{(${String}.match(/\\d+/))}
javascript{parseInt(${String}, 10);}
javascript{parseInt(${String})}
But when I try those, I get an error in selenium IDE
[error] Unexpected Exception: fileName -> chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js, lineNumber -> 2531
I'm sure it's probably a basic newbie mistake, but I can't figure out what I'm doing wrong.