Response Time in Robot Framework - appium

Is there any way to know the time taken for each action to finish in Robot Framework???
Like For example, I want to rotate screen 90 degrees 10 times, how to time it or how to average the time taken by these actions??

The simplest solution is to get the current time, run your keyword or keywords, then get the current time again, Then, subtract the starting time from the ending time.
Robot framework provides a DateTime module that has functions to support this. For example, Get current date can return the current date and time. Subtract date from date can return a timedelta which can be formatted to days, hours, minutes, seconds, and milliseconds.

You can see it in your report.
http://robotframework.org/QuickStartGuide/report.html
Elapsed Time: 00:00:00.284
It is also available at Keyword Level in the Test Execution Log.

${date1} = Get Current Date
TestCase_To_Rotate_Screen_10_Times
${date2} = Get Current Date
${actiontime} = Subtract Date From Date ${date2} ${date1}

Related

Running a server with LUA and I need to trigger a function at a specific time every day

So I'm running a LUA script that executes every minute, this is controlled by software and I can't control the timing of the execution. I would like to check the time every day and trigger a function at a specific time. However, I would like to execute another script 5 minutes before that happens.
Right now I'm doing a string comparison using os.date() and parsing it to a string. It works, but the code isn't pretty and if the time changes, i have to manually change the time in two different variables, I'm pretty new to LUA so I've been having difficulty figuring out the best way to do this.
So the question is, how do I set a time variable, and compare that variable to os.date (or os.time) ?
There's no fancy way to do timers in pure Lua. What you can do to avoid os.date() strings, is to generate timestamps with preset dates, os.time accepts a key-value table to set a date:
timestamp = os.time({year=2019, month=1, day=n})
By iteratively increasing the n variable, you will receive a timestamp for every new n day after January 1st 2019. E.g.
os.date("%Y-%m-%d %H-%M-%S",os.time({year=2019,month=1,day=900})
--> 2021-06-18 12-00-00
If you can't save the day variable to keep track of (between application restarts), get the current "today" day and iterate from there:
os.date("%Y-%m-%d %H-%M-%S",
os.time({year=os.date("%Y"),month=os.date("%m"),day=os.date("%d")+n}
)
Using os.date with custom format and os.time makes your code independent of currently set date locale.
After you have determined the timestamp of the first task, offset the second actual task by five minutes secondTaskTimestamp = fistTaskTimestamp + 5*60 (or use os.time again). Your timer checker only should compare timestamps by now.
Now when you have to change the pre-configured time, you will only have to change the time-date of the first task, and the second task will be automatically offset.
Related: How do I execute a global function on a specific day at a specific time in Lua?

How do I add duration to a time in Google Sheets?

I've found a few answers to questions similar to this elsewhere, except with adding or subtracting two times to get a duration, however, I haven't been able to figure it out enough to meet what I want.
I'm trying to get the time that I woke up using the time that I went to bed and the duration. I've tried doing [Time] + [Duration], however when I do that I get a value like 10060:25:00. I've also tried adding the hour value of the duration and the hour value of the time and dividing by 24, but that didn't work either. I did figure out the minutes though, all I did was =MOD([Time minute value]+[Duration minute value],60).
So to clarify, I just need to find the hour value now.
I am not exactly sure if this answers your question, but I think it is very similar. And I apologise in advance for an unnecessarily complicated description.
Sorry I didn't have time to provide a shorter answer.
I wanted to create a run sheet for a workshop with session durations.
I have a start time, and each session has a duration. I can then calculate start time for next session and cumulative duration of the sessions.
column label :> A || B || C || D
Heading label:> start_time || duration || hidden_duration || Elapsed
Number format:> date/time || number || duration ||duration
new start_time=previous_start_time+hidden_duration
hidden_duration=if(isblank(duration),"0:00:00","0:"&duration)
It seems time is particular about how it interprets a number. This is where the duration format fits in, as it formats correctly to add to time. However, a field formatted as a "duration number format", must then be entered as a duration. In other words, it is expected as 00:00:00.000 which is very particular. Or in fact, it appeared it at least needed 00:00 i.e. Hours and minutes separated by colon.
As I only had minutes, I didn't want to have to enter in this particular format all the time; and if I was to put 5 in the duration field, it was being interpreted as 5 milliseconds (or something). So I have used a simple number in the duration field and inserted it into a string in the hidden_duration field to form 0:duration. For example to add 5 into the minutes column of the hidden_duration entry it would be "0:"&5. The if(isblank(),...test was necessary to avoid blank durations voiding all the way down the column. i.e. If duration was blank, add 00:00:00 time to the start_time.
Start_time Duration Hidden_duration Elapsed
08:30:00 15 =if(isblank(B2),"0:00:00","0:"&B2&":00") =C2
=A2+C2 5 =if(isblank(B3),"0:00:00","0:"&B3&":00") =D2+C3
Drag the second row down to repeat however many entries you will have.
Don't forget to make the appropriate columns the correct number formats.
Also, you can modify the duration formats using Format | Number | More formats| Custom Number Formats and removing the unwanted display fields (such as seconds).
Then, I also made some conditional formatting rules, so that if a duration was blank, the Elapsed and time cells were white text on white background so they looked blank.
For your application you could do the same but have separate hours and minutes columns to make for easy data entry, both being used in the "hidden_duration" formula.
I hope I have helped here, as I found your question, trying to do the same and Googling an answer, but then ended up experimenting and discovering some new things myself.
Someone more knowledgable may be able to correct my entry or make more efficient. {Or at least explain more efficiently (; }
=HOUR(B2-A2)+(MINUTE(B2-A2)/60)
Basically, being B2 the end time and A2 the start time, you subtract B2-A2 and get the hour from the subtraction. Then you do the same and get the amount of minutes. After you have both, you sum the amount of hours with the amount of minutes divided by 60 (to get it in hours).
Don't forget to use the 24-hour format (i.e. 10:00 or 22:00).

ios: find real time since previous app launch

SO basically all is in the title. I've searched quite a lot, but didn't find any right solution which doesn't require internet connection.
If the user changes time in settings - i can't find real time since last launch.
I need that for my game, in it for every hour, even when you don't play the game, you get some coins.
If the user changes time in settings - that affect the time in NSDate() and user can cheat with coins.
So save the NSDate() to user defaults on app launch. The next time the app comes to the foreground, or gets launched again, get the current NSDate and subtract the saved date from it. That will give you the number of seconds between the two dates. Calculating hours from seconds is a simple matter of dividing by 3600. – Duncan C just now edit
EDIT:
Note that in newer versions of Swift (starting with Swift 2?) Most Foundation classes were defined as native Swift classes without the NS prefix. For newer versions of swift, replace all occurrences of NSDate with Date in the above.
Also note that in iOS ≥ 7.0, the Calendar has some methods that make this sort of calculation neater and easier. There's a new method dateComponents(_:from:to:) that lets you calculate the difference between 2 dates in whatever units you want. You could use that to calculate the seconds between the 2 dates more cleanly than calculating seconds, as outlined in my original answer. Calendar methods also tend to handle boundary conditions like spanning daylight savings time, leap seconds, etc.
Consider the following Swift 4/5 playground code:
import UIKit
let now = Date()
let randomSeconds = Double.random(in: 100000...3000000)
let later = now + randomSeconds
if let difference = Calendar.current.dateComponents([.second],
from: now,
to: later)
.second {
print(difference)
Try this.
Step 1. When user exits game. Set a NSUserDefault with current time.
Step 2. When app launches, in your appDelagate file, get this value.
Step 3. Calculate diff between and award coins accordingly.

Check isDaylightSavingTime for

The Using Time Zones Guide
shows how to check if daylight saving time (DST) is in action for the current date and how to get the next date when daylight saving time changes. With calls to:
isDaylightSavingTime
daylightSavingTimeOffset
nextDaylightSavingTime
E.g.
Bool isDST = [[NSTimeZone systemTimeZone] isDaylightSavingTime];
But I need to find out if a future date is DST or not so that when users scroll to a distant and far off date, they can see my graph plotted with the time axis labelled correctly (GMT or BST).
The problem is that isDayLightSavingTime seems to take two parameters, one passed to it explicitly (NSTimeZone) and the other implicitly, namely the current system time.
You just need to call isDaylightSavingTimeForDate, passing in the relevant NSDate.
It's not that isDaylightSavingTime itself has two parameters - it's that it calls isDaylightSavingTimeForDate with the current date. From the docs for isDaylightSavingTime:
This method invokes isDaylightSavingTimeForDate: with the current date as the argument.
So just skip the "convenience" method and call isDaylightSavingTimeForDate specifying the date you want to check. (I'd give some sample code, but the chances of me getting Objective C syntax correct are very slim...)

get time left until #post.created_at in seconds

Looking for a way to get the seconds until #post.created_at date time with timezone.
Using DateTime.now.in_time_zone to get the current date and time. I can use the ruby time helpers but I really only need the seconds.
There is distance_of_time_in_words but no distance_of_time_in_seconds helper
how would you calculate seconds away (left until) a certain #post.created_at?
A simple
#post.created_at - Time.now
..will give you the seconds. You need not have to worry about Time Zones, because Rails will be handling the time zones (since both are objects with time zone details with it), before calculating the difference.
(Time.now.in_time_zone - #post.created_at.in_time_zone).to_i
Will return the difference in seconds.

Resources