how to compare a variable with blank value in selenium? - selenium-ide

I want to check whether the variable is storing blank value or not.
I tried out comparing it with '' or "" or NULL or null, but does not work.

You can try out below solution
storeValue | element | test
store | | j (blank value)
gotoIf | storedVars['test']==storedVars['j'] | true
getEval | alert("test Variable Value is not blank")
gotolabel | finish
label | true
getEval | alert("test Variable Value is blank")
label | finish

You can also use verifyEval command for this. Try following script,
verifyEval | this.page().findElement("id=gbqfq").value == '' | true

Related

Pushing into array Selenium IDE 2019

I'm trying to populate an array automatically.
These stepes just returns an array containing "foo". The "bar"-string I'm trying to push into it doesnt seem to be included.
execute script | return ["foo"] | testVar
execute script | ${testVar}.push("bar") |
echo | ${testVar}
What am I doing wrong?
I use this approach to update an array in Selenium IDE
execute script | return ['foo'] | testVar
execute script | return [${testVar}, 'bar'] | testVar
echo | ${testVar}
UPDATE
Previous solution is not correct because of wrong value will be stored in the variable testVar. It will be array of array of arrays. So here is the correct one:
execute script | return ['foo'] | testVar
execute script | tmp = ${testVar}; tmp.push('bar'); return tmp; | testVar
echo | ${testVar}

How to split the denominator value from one column and store it in another column using perl?

My example code output:
time | name | status | s_used | s_max |
+------------+-------------+-----------+------------+-----------+
| 1482222363 | asf | Closed | 0/16 | 0 |
| 1482222363 | as0 | Available | 4/16 | 4 |
I have attached the part of my output which is generated using perl cgi script and mysql database.
My query is how to take denominator value from the column s_used and store only the denominator values in the s_max column using perl.
3.I had attached the following part of code which i tried.
if($i == 4){
if(/s_used/){
print;
}
else{
chomp();
my($num,$s_max)=split /\//,$table_data{2}{'ENTRY'};
print $s_max;
}
}
Code Explanation:
$i == 4 is the column where should I store the variable.
I got time column from the sql database $time, name I got from $table_data{0}{'ENTRY'}, status from $table_data{1}{'ENTRY'}, s_used from $table_Data{2}{'ENTRY'}.
Expected output:
time | name | status | s_used | s_max |
+------------+-------------+-----------+------------+-----------+
| 1482222363 | asf | Closed | 0/16 | 16 |
| 1482222363 | as0 | Available | 4/16 | 16 |
Seems your code "my($num,$s_max)=split /\//,$table_data{2}{'ENTRY'};" is right.
Somehow the value $s_max at the time it's writing to the DB is incorrect. Since you did not post the portion of code to show the part $s_max writing back to the DB, you need to check what value is in $s_max (e.g. printing the $s_max value) at the time right before writing it back to DB. From there, please try to trace back why an incorrect value is assigned to $s_max. Then, the problem would be solved.

Pure Data from print~ to print second element with print

With the following program, I get a big list out of print~.
I want to a get the second value from this list.
How to get this second value and print it with print and not print~?
[print~] will always print the entire signal-block (in your case 128 values).
to get a specific sample, you could instead use a table, feed the monitored signal into it, and retrieve the value(s) you are interested:
...
|
[tabsend~ $0-foo]
[table $0-foo 128]
[2(
|
[tabread $0-foo]
|
[print]
note: unlike with [print~], which will only generate output at the next signal block, this will output the data immediately (that is: it will take the signal data from the last signal block).
to get the next signal-block, you can replace the lower part of the suggested solution with something like the following:
[bang~] [2(
| |
| [r $0-next] |
| | |
[spigot] [t b f]
| | |
[t f b] [1( |
| | | |
| [0( [s $0-next] |
| | |
| [s $0-next] |
| |
[float ]
|
[tabread $0-foo]
|
...
(the patch uses [s/r $0-next] to avoid cross-over connection lines in the ascii graphics; in practice you probably want to use straight connections instead)
it's probably best to encapsulate the entire thing into an abstraction.

Selenium IDE - Array add values

Let's say I have two String variables: var1 and var2.
Is there any command on Selenium IDE (maybe storeEval with some javascript code), with which I can create an array and add the 2 variable values to it? Example:
var1 = "abc"
var2 = "def"
array = ("abc","def")
P.S: the array cannot have a fixed length. In this case I have just 2 variables, but in other scenarios I may have more than 10 variables, so I would need to create a loop and add all 10 variable values to the array.
Thanks!
It's pretty simple but isn't obvious
storeEval | ['one','two'] | array
storeEval | storedVars['array'][1] | second
echo | ${second}
Or simpler but with much less safety
storeEval | ['one','two'] | array
echo | javascript{storedVars['array'][1]}
Adding new item dynamically
getEval | storedVars['array'].push('three')
You can make loop using selenium IDE flow control for example. Like:
storeEval | 0 | i
while | storedVars['i']<storedVars['array'].length
echo | javascript{storedVars['array'][storedVars['i']]}
storeEval | ${i}+1 | i
endWhile
I hope it will help

Postfix is reserved error

The below is my code entered to Swift 2 and getting the error saying "postfix is reserved".
Can anyone tell me how this went wrong?
if (PFUser.currentUser() == nil){
self.loginViewController.fields =
PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton | PFLogInFields.SignUpButton | PFLogInFields.PasswordForgotten | PFLogInFields.DismissButton
Can you ensure that your OR compound expression does not contain spurious spaces?. I can spot one before the .LogInButton. I have corrected it here. Please check-
if (PFUser.currentUser() == nil){
self.loginViewController.fields =
PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton | PFLogInFields.SignUpButton | PFLogInFields.PasswordForgotten | PFLogInFields.DismissButton