appears Javascript date and time commands do not work
I have a number of javascript commands that i use to set date stamps for screenshots, and the commands appear to fail.
Attempting to use "storeEval" - is there an alternative to be used?
Trying to execute storeEval on new Date().getFullYear() with value year... Failed:
Unknown command: storeEval
Not atm, it's not date and time commands rather than eval command. Duplicate of #138
thanks . Is there an alternative for a work around?
Depends on what you want to do.
Having a flexible tool like that is very important, but we need to introduce the right sandboxing mechanism to uphold user's protection.
basically I need to be able to get the month, date, and year, so that I can use the variable as a part of time stamp for my screenshots, and also I can use these variables for data verification. My application picks dates, so I've built a mechanism to automatically update the date as I run the test daily. This also adds a date stamp to when I create Users IDs.
This is now very similar to #162, which wants eval but for a safe use-case.
I'll post later today an issue about storeSafeEval and what safe means, and in what ways it's gonna be limited compared to storeEval.
I use the store command for pretty much the same thing, but also use it to parse data in a variable.
<tr>
<td>storeText</td>
<td>//p/b[text()='Order#']/..</td>
<td>t1</td>
</tr>
<tr>
<td>echo</td>
<td>${t1}</td>
<td></td>
</tr>
<!-- parse data -->
<tr>
<td>store</td>
<td>javascript{storedVars["t1"].split(" ")["1"]}</td>
<td>mloUID</td>
</tr>
Will the store command still allow js?
This is what I use to store the current time in a variable for use currently, haven't tried it in the new IDE yet: get todays date format mmddyyhhmmss
<tr>
<td>store</td>
<td>javascript{ var fd=new Date(); var date_month=fd.getMonth()+1; if (date_month < 10){ date_month = "0" + date_month; }; date_day = fd.getDate().toString(); var n=date_day.length; if (n < 2){ date_day = "0" + date_day; }; date_hour = fd.getHours().toString(); var n=date_hour.length; if (n < 2){ date_hour = "0" + date_hour; }; date_min = fd.getMinutes().toString(); var n=date_min.length; if (n < 2){ date_min = "0" + date_min; }; date_sec = fd.getSeconds().toString(); var n=date_sec.length; if (n < 2){ date_sec = "0" + date_sec; }; date_year=fd.getFullYear().toString(); date_year = date_year.toString().substr(2,2); date_month+""+date_day+""+date_year+""+date_hour+date_min+date_sec; }</td>
<td>dateToday</td>
</tr>
the store command as far as I see still works. It's just the storeEval command that appears to not be there.
I will explain what I can do while being a good guy with Mozilla and Google,
For basic javascript evaluations it should be enough.
Mostly it will restrict what you can access in the application.
For example you wont be able to change a value of an input through it.