I posted other posts too for "storeEval". Click here to view more tutorials of selenium IDE "storeEval" command. In software testing using selenium IDE, many times you needs to verify or compare the number of records list during activity like searching, adding or deleting records. Generally, record count displayed on
page like "24500 records found.", "24500 records available." or "24500 orders found." etc. Now if you store this full string to compare records then it is not possible. For comparing numbers, you need to extract numeric value from string. Let me give you example of extracting number from string.New Test | ||
Command | Target | Value |
store | 24500 Records Found. | string |
storeEval | storedVars['string'].match(/^\\d+/); | number |
gotoIf | storedVars['number'] >= 225 | greater |
echo | Records are less than expected... | |
gotoLabel | exit | |
label | greater | |
echo | Records are greater than expected... | |
label | exit |
Run above script in selenium IDE. Here, "storeEval" will extract number '24500' from string '24500 Records Found.' using javascript statement "storedVars['string'].match(/^\\d+/);". Then i can use its value to compare with conditional command "gotoIf".
Hi,
ReplyDeleteI have a problem similar to this one.
What do I have to do if there's some kind of string in front of the number I want to extract?
My string is '(XX)' where XX is a number.
I can extract the number from 'XX)' but not from '(XX'.
I tried "storedVars['string'].match(\d+//^\);" for '(XX' but it says "illegal character".