Difference between runScrip and storeEval commands - selenium-ide

I am a beginner in testing. I am doing my internship on testing and trying to learn about all the commands in selenium IDE. I would really appreciate if someone could help me. I want to know the difference between runScript and storeEval commands. I understand the basic difference by the reference but i want to know in detail. Thank you.

Try to do:
runScript | somethingwrong
storeEval | if (1==1) 'lol' //Or any valid js | somevar
echo | ${somevar}
echo | javascript{if (storedVars['somevar'] != 'lol') {'???';} else {'We can do js here too'}}
storeEval | somethingwrong | somevar
getEval | somethingwrong
verifyEval| storedVars['somevar'] == 'lol' | true
verifyEval| {if (1==1) true} | false
And run each line with doubleclick one by one.
runScript
It's returning nothing. And it is not wrapped by selenium IDE. It means that wrong script will not cause any error in selenium IDE. But it will cause js error in the browser. It may be useful if you want to use browser debugging tools to treat some js error
storeEval
It is storing result of a javascript to a variable. And it is wrapped by Selenium IDE it means that broken script will cause error right in the Selenium IDE and test will be stopped in that case. You will be able read error right in the Selenium IDE log.
echo
Can run javascript too. But please do it for debugging only. If your js is broken it will hang the test.
getEval
It's returning no result. Everything else like in storeEval. Broken js will fail the test.
verifyEval
Is for verifying variables. It will fail the test in case if two evals provided are not equal. You can use to run javascript too. It is very useful when you need not only get the result of javascript but fail the test if your the result is not acceptable.
So:
runScript is to just do script and go further (maybe with errors in browser console)
getEval is to run script and fail in case of something wrong
storeEval is to run script and retrieve the result to use it later
verifyEval is to run script and verify the result.
echo is not for running scripts. But you can do it. For debugging only.
There are a number of other ways to run script using Selenium IDE. But it's already a lot.
Hope it will help.

Related

why scala puts the version on stderr instead

I have to do this:
scala -version 2>&1 | sed 's/.*version \([0-9]*\.[0-9]*\).*/\1/'
Instead of this:
scala -version | sed 's/.*version \([0-9]*\.[0-9]*\).*/\1/'
so I am wondering why does scala -version (sometimes maybe ...) put its result on stderr?
Actually, in Unix stderr is not used for errors only.
It's more like stdin and stdout are using for the default piping streams (cmd1 | cmd2 | cmd3) and sdterr is everything that the command creators thought that should not go into this default pipeline, and instead should be shown to the user who build it. It includes errors, but sometimes also information about progress, configuration, diagnostics, etc.
Let's see some example of that:
echo "2 + 2 * 2" | scala | grep "res"
This would treat scala as something that takes source as input and prints the results of evaluation on output. But it still prints some stuff on stderr, and when you run it you'll see
Type in expressions for evaluation. Or try :help.
Jul 08, 2022 9:32:44 AM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
scala> val res0: Int = 6
On a first glance it is redundant but when you look closely it tells some interesting things like WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information) which is nice to see as you are debugging your script, and not go into the stream where you are only expecting to see the results of the execution.
What would happen if you added -version after scala?
> echo "2 + 2 * 2" | scala -version | grep "res"
Scala code runner version 2.13.8 -- Copyright 2002-2021, LAMP/EPFL and Lightbend, Inc.
Script still runs - it's shell so you can glue a lot of things together whether it makes sense or not, so it's expected. But this script doesn't do anything reasonable - there is no code processing output from scala -version and if version landed on stdin you'd see empty result, not knowing what happened. But since it landed on stderr you see what happened, and can fix the script.
And if you actually wanted to process scala -version output, it's just one 2>&1 away as you noticed.
There are also other things to consider like mentioned in comments: consistency with what java -version does, no promise to print such information to stdin. Also, it might have been made this way to be internally consistent: scala might use stdin for code input and stdout for code execution exclusively, and anything else is wired to some global logger printing on stderr. Finally, while there are some conventions what should and should not go into stderr, none of that is set in stone, so you should not come with predefined expectations. Authors will do what they find the most pragmatic.

Perl debugger on test modules

I'm running into problems testing a new addition to a module. (Specifically - the ~ operator seems to be not working in Math::Complex for this new feature only.) It's too bizarre to be what it appears but the ideal scheme would be to add the -d option on the top line of the .t program.
Well, I was quickly disabused of that idea! It does not invoke the debugger.
If I wanted to use the debugger, I'd need to create an edit of the .t program that:
Uses (the use command) the module directly. not in the form of
BEGIN { use_ok('My::Module') };
Does not "use Test::More;"
A few other edits that cause gluteal pains
The problem with doing that is that any changes I make in the edited test program I still need to transfer back to the true test program use in "make test". Error prone as best.
I am already using "make test TEST_VERBOSE=1" so that my stdio output shows up. But there's GOT to be a simpler way to invoke the debugger on the .t
Thanks for ideas here.
-- JS
use_ok tests are great, but you should have them in test files of their own, not test files that also test other things.
I'm not sure why you would need to avoid Test::More or use_ok to run the debugger, though. What does happen when you try your test directly:
perl -d -Mblib t/yourtestfile.t?
If all else fails, you can try using Enbugger in your test script.

"scala" command terminates batch scripts

during my work here I collided with a somewhat peculiar problem. It's possible that there is a highly simple explanation for this behaviour, but to me it just doesn't make much sense.
Here's the situation:
I wrote a batch file "test.bat" that, right now, looks like this:
echo 1
scala myProgram
echo 2
When I open the command prompt in the according directory and run test.bat, it starts by echoing 1, then runs myProgram (which also has certain outputs that appear in the console, so the scala program myProgram works properly) - and then stops. 2 does not appear in the console and the console waits for me to input another command.
Why this behaviour? Is is a malfunction of the console? Or of the scala command? Or not a malfunction at all and it is actually meant to behave that way?
What I was actually trying to do is redirecting the output of "scala myProgram" to a file (which works well) and rename this file after the scala program has terminated, so my batch file originally looked somewhat like this:
scala myProgram > log.txt 2>&1
ren "log.txt" "log2.txt"
And I was confused about the fact that "log2.txt" was never created.
Your answers are greatly appreciated, thank you.
Adding -nc to scala command worked for me:
$ scala -nc /tmp/2.scala
Hello world
So I guess, the issue has something to do with the compilation daemon
-nc no compilation daemon: do not use the fsc offline compiler
Could you try that?

Output selenium test result as html after running perl script

I am currently looking for a way to output the test result nicely after running selenium perl script.
The htmlSuite command from running selenium server outputs a nice html format result page, but I don't know how to do that in perl script.
Problem is, I have it setup so that Selenium is being run 24/7 on a virtual machine workstation(Windows 7), where anyone one can run tests on. Therefore I can't use htmlSuite to run the test because the server will close after the test is finished.
Is there a command argument or perl script method to make selenium server output results on html or other nice format other than printing it on the command line?
Or is there a better way to do this?
If your script is output TAP (that's what Test::More would put out), then you can use the Test::Harness family of modules to parse that TAP and use it to generate an HTML report.
How nice is nice? Under Hudson/Jenkins this gives graphs and a tabular report of tests run:
prove --timer --formatter=TAP::Formatter::JUnit large_test.t >junit.xml

Fitnesse command line fixture

Does anyone have/"run into" a Fitnesse a Windows commnand line fixutre? I need to run executables then run my test suites and would appreciate if someone has such a fixture laying around.
Basically, what I am trying to do is the following:
|CommandlineFixture|
|C:\dev\myFileImporter.exe -f c:\dev\data\file.txt|
If you're using Fit, you can try Bob Martin's CommandLineFixture. You can use it by creating a simple test table as follows:
| com.objectmentor.fixtures.CommandLineFixture |
| command | C:\dev\myFileImporter.exe -f c:\dev\data\file.txt |
It also has some nice functionality like being able to search stderr/stdout for certain messages, wait for forked processes to finish, etc.
It's written in Java, and source code is available in case you have to customize it (when I used this, I customized it fairly heavily to add new functionality).