Open drumenbas opened 4 years ago
So I could have sworn I tried with replace before I tried with match, seems that works fine
Command | Target | Value |
---|---|---|
store | Your verification code is: 149599. Your code will expire in five minutes. Please do not reply. | sms |
echo | SMS = ${sms} | |
execute script | return (${sms}.replace(/[^0-9]+/g, "")); |
code |
echo | Code = ${code} | |
execute script | return (${sms}.match(/\d+/g, "")); |
code |
echo | Code = ${code} |
match() fails, replace() works
So not sure if a bug, please feel free to close if not.
@drumenbas Stupid question but I was actually looking for a way to get data out of the script with command runner. Do you know of any way to store the information (e.g. your verification code) in the log file? Or any external file for that matter.
@sabatale there is no such thing as stupid questions... Have not really played with the --output switch, but it logs the basic test statistics, so not much use there.
Now you could use some console output switch, eg. under windows your execution command would look like
selenium-side-runner -c "browserName=chrome" sms.side 1> myoutput.txt 2>&1 && type myoutput.txt
The downside is you don't see the execution progress, only at the end it writes the text to file and console text.
Where normally you would see this
You will get something like this
But you get a txt file containing the output looking like this
You totally hijacked my bug report 0_o
This is definitely still a problem with regex strings in general. I'm trying to do a .match on a string in the runner and it's returning null.
I'm guessing it's an escaping problem (/\d+/g
getting interpreted as /d+/g
in this case).
E: Actually, just fixed it. I had to add an extra \\
before each \\
in the outputted .side file. Thankfully it still works in the IDE. This should really get fixed.
🐛 Bug Report
Recorded a test case that stores text into a variable called 'sms', running a regex script to extract a number to be used later in the test case. When running tests in side-runner execute script javascript regex returns d,d,d
To Reproduce
Steps to reproduce the behavior: As per project sms.side
return (${sms}.match(/\d+/g));
Execute in cli:
selenium-side-runner -c "browserName=chrome" sms.side
Expected behavior
celenium-side-runner to be able to execute javascript regex value and store the value for reuse (example console log the echo 149599)
Actual behavior
Project file reproducing this issue
sms.zip
Environment
OS: Windows 10 Selenium IDE Version: v3.17.0 Selenium SIDE Runner Version: 3.17.0 Node version: v10.22.0 Browser Version: ChromeDriver 85.0.4183.38