Verify time with 3 seconds buffer - datetime

Get Current Audio Upload Time
${time}= Get Current Date
${converted-time}= Convert Date ${time} result_format=%H:%M:%S
Log To Console time is ${converted-time}
Set Global Variable ${converted-time}
this script verifies that after searching the string, the result is returned then verify time is correct.
however, there is elapsed when the robot captured the current time vs the application captured time.
I cannot verify it directly, I need to give 3 seconds buffer.
robot captured time: 16:38:04
app captured time: 16:38:56
Verify Audio Time
[Arguments] ${RandomNumber}
Wait For Elements State //mark[text()='Dual-Channel-Audio-${RandomNumber}']//following::td[text()='${converted-time}']
UI which shows time

Related

For Loop is not looping untill the given range in robot framework

sleep till Rest api
FOR ${i} IN RANGE 20
Sleep 5s till rest api is available
${result} = Check Rest Api
Exit For Loop If ${result} == True
Log to Console try again in 5 sec
END
I am using For loop to sleep for some time until the api is available and exit from loop once it has got the response. For this I had stored the result of the keyword in a varibale and gave exit from loop when result becomes true. But, whats happening is first it waits for 5 seconds and checks the result and fails. After failing once it is not iterating and fails at checking the result itself.
Here when it goes through the second line in for loop ( ${result} = Check Rest Api ). The sleep time is not sufficient and it fails at that statement itself. What I am expecting is the loop should continue until it gets the response.

Apache Airflow: rerun for tasks with date parameters

I have a hourly shell script job that takes a date and hour as input params. The date and hour are used to construct the input path to fetch data for the logic contained in the job DAG. When a job fails and I need to rerun it (by clicking "Clear" for the failed task node to clean up the status to re-trigger a new run), how can I make sure the date and hour used for rerun are the same as the failed run since the rerun could happen in a different hour as the original run?
You have 3 options:
Hover to the failed task which is going to clear, in its displaying tag there will be a value with key Run:, it is its Execution date and time.
Click on the failed task which is going to clear, heading of its displaying popup which has the clear option will be [taskname] on [executiondatewithtime]
Open the task log, the first line after the attempts count will be included a string with format Executing <Task([TaskName]): task_id> on [ExecutionDate withTime]

Set Timeout for Page loading in robotframework

I want to put a check on response time in page loading when my test runs through multiple pages.
If a page doesn't load within 2 seconds, test should fail.
I am using Robot Framework with Selenium2Library and everytime I would use command Wait Until Page Contains text 2s, the browser will wait for page to be loaded completely and then run this command which does not serve the purpose.
Is it possible to put a timeout on page loading in Robot Framework?
The default selenium behavior is to wait for the page to be loaded before returning the control (with the exception of some ajax calls done by the js). So in the vanilla Go To navigation call the execution will continue after the load has happened - and thus the Wait Until ... passes almost immediately.
Selenium supports overriding this behavior by settings in the desired_capabilities, but that can be a bit involving (the setting for Firefox is called "pageLoadStrategy", with the values none/eager/normal, for example).
Here's something much easier though - just use a timer, get the timestamps before and after the navigation, and the diff will be the full page load.
${before}= Get Current Date result_format=epoch
Go To https://your-url
${after}= Get Current Date result_format=epoch
Should be True ${after} - ${before} < 2 msg=The total page load time was more than 2 seconds!
The keyword Get Current Date is in the DateTime standard library, and when called with the argument "result_format=epoch" it returns a float (the seconds since 1970) - the fractional part is the milliseconds.
By subtracting the two values you get the full page load time.

GotoIf hash key pressed at the end of Record command

We ask the caller to record their name then press hash key #. If the hash key has been pressed they should move to next step, otherwise go back and ask them to record the name again.
exten => s,n(RecordName), Playback(Please Record Your Name After Beeb then press '#')
exten => s,n,Record(recordpath/namefile.wav,60)
exten => s,n,GotoIf ('# isn't pressed')?RecordName)
Is there any way to detect if # is pressed at the end of Record command?
Please check documentation of Record command.
It clearly say which variables it set on # key.
pro-sip*CLI> core show application Record
-= Info about application 'Record' =-
[Synopsis]
Record to a file.
[Description]
If filename contains '%d', these characters will be replaced with a number
incremented by one each time the file is recorded. Use 'core show file formats'
to see the available formats on your system User can press '#' to terminate
the recording and continue to the next priority. If the user hangs up during
a recording, all data will be lost and the application will terminate.
${RECORDED_FILE}: Will be set to the final filename of the recording.
${RECORD_STATUS}: This is the final status of the command
DTMF:A terminating DTMF was received ('#' or '*', depending upon
option 't')
SILENCE:The maximum silence occurred in the recording.
SKIP:The line was not yet answered and the 's' option was specified.
TIMEOUT:The maximum length was reached.
HANGUP:The channel was hung up.
ERROR:An unrecoverable error occurred, which resulted in a WARNING
to the logs.
[Syntax]
Record(filename.format[,silence[,maxduration[,options]]])
[Arguments]
format
Is the format of the file type to be recorded (wav, gsm, etc).
silence
Is the number of seconds of silence to allow before returning.
maxduration
Is the maximum recording duration in seconds. If missing or 0 there
is no maximum.
options
a: Append to existing recording rather than replacing.
n: Do not answer, but record anyway if line not yet answered.
q: quiet (do not play a beep tone).
s: skip recording if the line is not yet answered.
t: use alternate '*' terminator key (DTMF) instead of default '#'
x: Ignore all terminator keys (DTMF) and keep recording until hangup.
k: Keep recorded file upon hangup.
y: Terminate recording if *any* DTMF digit is received.
[See Also]
Not available

events (as a json feed), start end parameters unix timestamp, are different if I change my OS time zone

I'm using the fullcalendar plugin and would appreciate if someone can give me a hand.
I am getting json events through a PHP URL.
something like this:
$('#calendar').fullCalendar({ events: "/myfeed.php" });
So in my php page that returns the events, I am getting 3 GET parameters:
'_'
'start'
'end'
The start and end parameter, indicate the date in UNIX timestamp.
So far so good, the problem that occurs is that if I change the time zone on my OS. also change these parameters start and end, for the same query in the same day in the calendar.
the weirdest part is that it only happens in Mozilla Firefox.
in Google Chrome, this problem does not occur.
e.g.
I have set my time zone ((UTC-04: 00) Santiago)
I'm referring to the day 09.09.2012 on the agenda,
firebug shows me that these parameters are being sent to my php page
_ 1347245953581
end 1347246000
start 1347159600
but if I change the time zone from my OS to ((UTC-03: 00) Buenos Aires)
consulting on 09.09.2012 on the agenda,
are other parameters which are now sent to the PHP page.
_ 1347246338047
end 1347332400
start 1347246000
Being that it is the same day, are other start and end parameters which are sent to check for events.
There is an ignoreTimezone option on the fullcalendar that might help. I'm not sure if it affects the start/end time passed to the feeds.
http://arshaw.com/fullcalendar/docs/event_data/ignoreTimezone/
Another option is to convert the passed timestamp to a Date object and get the local data from the Date object afterwards and use that in your queries.
Convert a Unix timestamp to time in JavaScript
I know it is not the exact answer, but it might help you out a bit.
Here is a sample piece of PHP code to convert the passed timestamp into a local formatted date:
$startts = $_REQUEST["start"]; // original timestamp
$startdt = new DateTime('now', new DateTimeZone('Europe/Oslo') ); // setup a local datetime
$startdt->setTimestamp($startts); // Set the date based on timestamp
echo $startdt->format('Y-m-d H:i:s'); // Output local date and time

Resources