Skip to content
Advertisement

How to pull multiple numbers out of a string in Selenium IDE version 3.17

In the latest version of selenium ide, I want to extract a number from a string and print that number elsewhere. What command should I use?

Advertisement

Answer

You can run JavaScript functions inside of Selenium IDE using the execute script command.

If your string contains only a single number (or several numeric characters in a row), you can extract that number using JavaScript’s match method with regex:

execute script | return ${stringWithNumber}.match(/d+/) | extractedNumber

Here’s an example:

Selenium IDE match example

Another option would be to use the substr method.

Advertisement