0

I would like to store the "FHCS79" out of "Your booking number is FHCS79" in a variable.

storeText css=h2 string<br>
echo ${string}

What is the smoothest way?

1

I would suggest you remove/ignore the first part of your string. in this case "Your booking number is " will be consistent, that way any remaining value (of any length) can be considered the booking number.

//---- remove only char in "Your booking number is "   
str = str.substring(23,(string.length));

Below is a synopsis of how the function works so you can expand it in the future

//---- remove first and last char of str    
str = str.substring(1,((string.length)-1));

//---- remove only first char    
str = str.substring(1,(string.length));

//---- remove only last char    
str = str.substring(0,(string.length));

An alternative is to use Slenium IDE's native Globbing pattern. Its not Quite as flexible but follows a similar pattern Further information on how to use "Globbing patterns" is available here

  • 1
    Thanks for your answer ECiurleo. Could you please help me put it in a Selenium IDE context since I'm quite a noob when it comes to coding? :). Would really appreciate it! – Johannes Apr 18 '16 at 11:55
  • I have added details of an alternative method to do the same thing but looks simpler. To use my above you "just" need to add it as a Regex in the Value field. If you are a new new user, it might be more complicated than is needed :) – ECiurleo Apr 19 '16 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.